예제 #1
0
        public static void CreateLayer(string layer_name)
        {
            PSX.CheckStringContents(layer_name);

            // Desc2
            var Desc2 = PSX.MakeNewDescriptor();

            Desc2.PutString((int)con.phKeyName, layer_name);

            // Ref1
            var Ref1 = PSX.MakeNewReference();

            Ref1.PutClass((int)con.phClassLayer);

            // Desc1
            var Desc1 = PSX.MakeNewDescriptor();

            Desc1.PutReference((int)con.phKeyNull, Ref1);
            Desc1.PutBoolean(PSX.StrToID("below"), PSX.FALSE);
            Desc1.PutObject((int)con.phKeyUsing, (int)con.phClassLayer, Desc2);

            int old_layer_count = LayerAPI.GetLayerCount(-1);

            // Play the event in photoshop
            PSX.PlayEvent((int)con.phEventMake, Desc1, (int)con.phDialogSilent, PSX.PlayBehavior.checkresult);

            LayerAPI.CheckLayerCount(-1, old_layer_count + 1);
        }
예제 #2
0
        public static PhotoshopTypeLibrary.IActionDescriptor [] CreateOpacityStops(double [] OA)
        {
            const int max_location = 4096;
            const int min_location = 0;

            System.Diagnostics.Debug.Assert(OA.Length > 1);

            var opacity_stops = new PhotoshopTypeLibrary.IActionDescriptor [OA.Length];
            int count         = 0;
            int step          = max_location / (OA.Length - 1);

            foreach (double O in OA)
            {
                System.Diagnostics.Debug.Assert(O <= 100);
                System.Diagnostics.Debug.Assert(O >= 0);

                int location = max_location - (step * count);
                System.Diagnostics.Debug.Assert(location <= max_location);
                System.Diagnostics.Debug.Assert(location >= min_location);

                const int midpoint = 50;
                opacity_stops[count] = LayerAPI.CreateOpacityStop(O, location, midpoint);
                count++;
            }
            return(opacity_stops);
        }
예제 #3
0
        static public void FlattenImage()
        {
            //PhotoshopTypeLibrary.IActionDescriptor Desc1 = PSX.MakeNewDescriptor();
            PhotoshopTypeLibrary.IActionDescriptor Desc1 = null;
            // Play the event in photoshop
            PSX.PlayEvent((int)con.phEventFlattenImage, Desc1, (int)con.phDialogSilent, PSX.PlayBehavior.checkresult);

            LayerAPI.CheckLayerCount(-1, 0);
        }
예제 #4
0
        public static void RasterizeLayer(int layer_index)
        {
            // Ref1
            var Ref1 = LayerAPI.GetReferenceToLayerByIndex(layer_index);

            // Desc1
            var Desc1 = PSX.MakeNewDescriptor();

            Desc1.PutReference((int)con.phKeyNull, Ref1);

            // Play the event in photoshop
            PSX.PlayEvent(PSX.StrToID("rasterizeLayer"), Desc1, (int)con.phDialogSilent, PSX.PlayBehavior.checkresult);
        }
예제 #5
0
        public static void DeleteLayer(int layer_index)
        {
            // Ref1
            PhotoshopTypeLibrary.IActionReference Ref1 = LayerAPI.GetReferenceToLayerByIndex(layer_index);

            // Desc1
            PhotoshopTypeLibrary.IActionDescriptor Desc1 = PSX.MakeNewDescriptor();

            Desc1.PutReference((int)con.phKeyNull, Ref1);

            // Play the event in photoshop
            PSX.PlayEvent((int)con.phEventDelete, Desc1, (int)con.phDialogSilent, PSX.PlayBehavior.checkresult);
        }
예제 #6
0
        public static void CheckLayerCount(int doc_index, int expected_count)
        {
            ///
            /// <summary>
            /// Raises an exception of the document count is not what is expected
            ///	Workitem: Move some of this checking into PSX
            /// </summary>
            ///

            int actual_layer_count = LayerAPI.GetLayerCount(doc_index);

            if (actual_layer_count != expected_count)
            {
                string msg = string.Format("Expected layer count of {0}, got {1} instead", actual_layer_count, expected_count);
                throw (new Photoshop6OM.PhotoshoProxyError(msg));
            }
        }
예제 #7
0
        public static PhotoshopTypeLibrary.IActionDescriptor [] CreateColorStops(System.Drawing.Color [] CA)
        {
            const int max_location = 4096;
            const int min_location = 0;

            System.Diagnostics.Debug.Assert(CA.Length > 1);

            var color_stops = new PhotoshopTypeLibrary.IActionDescriptor [CA.Length];
            int count       = 0;
            int step        = max_location / (CA.Length - 1);

            foreach (System.Drawing.Color C in CA)
            {
                int location = max_location - (step * count);
                System.Diagnostics.Debug.Assert(location <= max_location);
                System.Diagnostics.Debug.Assert(location >= min_location);

                const int midpoint = 50;
                color_stops[count] = LayerAPI.CreateColorStop(C, location, midpoint);
                count++;
            }
            return(color_stops);
        }
예제 #8
0
        public static void CreateTextLayer(string text, string fontname, int fontsize, string fontstyle, int antialias)
        {
            PSX.CheckEnum(fontstyle, "Regular", "Bold Italic", "Italic", "Bold");
            PSX.CheckEnum(antialias, (int)con.phEnumAntiAliasCrisp, (int)con.phEnumAntiAliasStrong, (int)con.phEnumAntiAliasSmooth, (int)con.phEnumAntiAliasNone);

            // Desc10
            var Desc10 = PSX.MakeNewDescriptor();

            Desc10.PutEnumerated((int)con.phKeyAlignment, (int)con.phTypeAlignment, (int)con.phEnumLeft);
            Desc10.PutUnitDouble(PSX.StrToID("firstLineIndent"), PSX.StrToID("pointsUnit"), 0);
            Desc10.PutUnitDouble(PSX.StrToID("startIndent"), PSX.StrToID("pointsUnit"), 0);
            Desc10.PutUnitDouble(PSX.StrToID("endIndent"), PSX.StrToID("pointsUnit"), 0);
            Desc10.PutUnitDouble(PSX.StrToID("spaceBefore"), PSX.StrToID("pointsUnit"), 0);
            Desc10.PutUnitDouble(PSX.StrToID("spaceAfter"), PSX.StrToID("pointsUnit"), 0);
            Desc10.PutBoolean(PSX.StrToID("hyphenate"), PSX.TRUE);
            Desc10.PutInteger(PSX.StrToID("hyphenateWordSize"), 8);
            Desc10.PutInteger(PSX.StrToID("hyphenatePreLength"), 3);
            Desc10.PutInteger(PSX.StrToID("hyphenatePostLength"), 3);
            Desc10.PutInteger(PSX.StrToID("hyphenateLimit"), 2);
            Desc10.PutDouble(PSX.StrToID("hyphenationZone"), 36);
            Desc10.PutBoolean(PSX.StrToID("hyphenateCapitalized"), PSX.TRUE);
            Desc10.PutDouble(PSX.StrToID("justificationWordMinimum"), 0);
            Desc10.PutDouble(PSX.StrToID("justificationWordDesired"), 1);
            Desc10.PutDouble(PSX.StrToID("justificationWordMaximum"), 1);
            Desc10.PutDouble(PSX.StrToID("justificationLetterMinimum"), 0);
            Desc10.PutDouble(PSX.StrToID("justificationLetterDesired"), 0);
            Desc10.PutDouble(PSX.StrToID("justificationLetterMaximum"), 0);
            Desc10.PutDouble(PSX.StrToID("justificationGlyphMinimum"), 1);
            Desc10.PutDouble(PSX.StrToID("justificationGlyphDesired"), 1);
            Desc10.PutDouble(PSX.StrToID("justificationGlyphMaximum"), 1);
            Desc10.PutBoolean(PSX.StrToID("hangingRoman"), PSX.FALSE);
            Desc10.PutBoolean(PSX.StrToID("burasagari"), PSX.FALSE);
            Desc10.PutEnumerated(PSX.StrToID("preferredKinsokuOrder"), PSX.StrToID("preferredKinsokuOrder"), PSX.StrToID("pushIn"));
            Desc10.PutString(PSX.StrToID("mojiKumiName"), "None");
            Desc10.PutBoolean(PSX.StrToID("textEveryLineComposer"), PSX.FALSE);
            Desc10.PutDouble(PSX.StrToID("autoLeadingPercentage"), 1);
            Desc10.PutEnumerated(PSX.StrToID("leadingType"), PSX.StrToID("leadingType"), PSX.StrToID("leadingBelow"));

            // Desc9
            var Desc9 = PSX.MakeNewDescriptor();

            Desc9.PutInteger((int)con.phKeyFrom, 0);
            Desc9.PutInteger((int)con.phKeyTo, text.Length + 1);
            Desc9.PutObject(PSX.StrToID("paragraphStyle"), PSX.StrToID("paragraphStyle"), Desc10);

            // List3
            var List3 = PSX.MakeNewList();

            List3.PutObject(PSX.StrToID("paragraphStyleRange"), Desc9);

            // Desc8
            var Desc8 = PSX.MakeNewDescriptor();

            Desc8.PutDouble((int)con.phKeyRed, 241);
            Desc8.PutDouble((int)con.phKeyGrain, 101);
            Desc8.PutDouble((int)con.phKeyBlue, 34);

            // Desc7
            var Desc7 = PSX.MakeNewDescriptor();

            //Desc7.PutString(  PSX.StrToID( "fontPostScriptName" )  ,  fontname  );
            Desc7.PutString((int)con.phKeyFontName, fontname);
            Desc7.PutString((int)con.phKeyFontStyleName, fontstyle);
            Desc7.PutInteger((int)con.phKeyFontScript, 0);
            Desc7.PutInteger((int)con.phKeyFontTechnology, 0);
            //Desc7.PutUnitDouble(  (int) con.phkey,  PSX.StrToID( "pointsUnit" )  ,  fontsize  ); SAVEEN
            Desc7.PutBoolean(PSX.StrToID("syntheticBold"), PSX.FALSE);
            Desc7.PutBoolean(PSX.StrToID("syntheticItalic"), PSX.FALSE);
            Desc7.PutBoolean(PSX.StrToID("autoLeading"), PSX.TRUE);
            Desc7.PutInteger((int)con.phKeyHorizontalScale, 100);
            Desc7.PutInteger((int)con.phKeyVerticalScale, 100);
            Desc7.PutInteger((int)con.phKeyTracking, 0);
            Desc7.PutBoolean((int)con.phKeyAutoKern, PSX.TRUE);
            Desc7.PutUnitDouble((int)con.phKeyBaselineShift, PSX.StrToID("pointsUnit"), 0);
            Desc7.PutEnumerated(PSX.StrToID("fontCaps"), PSX.StrToID("fontCaps"), (int)con.phEnumNormal);
            Desc7.PutEnumerated(PSX.StrToID("baseline"), PSX.StrToID("baseline"), (int)con.phEnumNormal);
            Desc7.PutBoolean((int)con.phKeyUnderline, PSX.FALSE);
            Desc7.PutBoolean(PSX.StrToID("strikethrough"), PSX.FALSE);
            Desc7.PutBoolean(PSX.StrToID("ligature"), PSX.TRUE);
            Desc7.PutBoolean(PSX.StrToID("oldStyle"), PSX.FALSE);
            Desc7.PutBoolean(PSX.StrToID("proportionalNumbers"), PSX.TRUE);
            Desc7.PutBoolean((int)con.phKeyRotate, PSX.TRUE);
            Desc7.PutEnumerated(PSX.StrToID("baselineDirection"), PSX.StrToID("baselineDirection"), PSX.StrToID("withStream"));
            Desc7.PutDouble(PSX.StrToID("mojiZume"), 0);
            Desc7.PutEnumerated(PSX.StrToID("gridAlignment"), PSX.StrToID("gridAlignment"), PSX.StrToID("roman"));
            Desc7.PutEnumerated(PSX.StrToID("hyphenationLanguage"), PSX.StrToID("hyphenationLanguage"), PSX.StrToID("englishLanguage"));
            Desc7.PutInteger(PSX.StrToID("wariChuCount"), 1);
            Desc7.PutDouble(PSX.StrToID("wariChuScale"), 1);
            Desc7.PutInteger(PSX.StrToID("wariChuWidow"), 25);
            Desc7.PutInteger(PSX.StrToID("wariChuOrphan"), 25);
            Desc7.PutBoolean(PSX.StrToID("noBreak"), PSX.FALSE);
            Desc7.PutObject((int)con.phKeyColor, (int)con.phClassRGBColor, Desc8);
            Desc7.PutBoolean((int)con.phKeyFill, PSX.TRUE);
            Desc7.PutBoolean(1400140395, PSX.FALSE);
            Desc7.PutBoolean(PSX.StrToID("fillFirst"), PSX.FALSE);
            Desc7.PutEnumerated(PSX.StrToID("verticalUnderlinePosition"), PSX.StrToID("verticalUnderlinePosition"), PSX.StrToID("verticalUnderlineRight"));

            // Desc6
            var Desc6 = PSX.MakeNewDescriptor();

            Desc6.PutInteger((int)con.phKeyFrom, 0);
            Desc6.PutInteger((int)con.phKeyTo, text.Length + 1);
            Desc6.PutObject((int)con.phKeyTextStyle, (int)con.phClassTextStyle, Desc7);

            // List2
            var List2 = PSX.MakeNewList();

            List2.PutObject((int)con.phClassTextStyleRange, Desc6);

            // Desc5
            var Desc5 = PSX.MakeNewDescriptor();

            Desc5.PutEnumerated(1413830740, (int)con.phTypeChar, 1349415968);

            // List1
            var List1 = PSX.MakeNewList();

            List1.PutObject(PSX.StrToID("textShape"), Desc5);

            // Desc4
            var Desc4 = PSX.MakeNewDescriptor();

            Desc4.PutUnitDouble((int)con.phKeyHorizontal, (int)con.phUnitPercent, 13);
            Desc4.PutUnitDouble((int)con.phKeyVertical, (int)con.phUnitPercent, 25);

            // Desc3
            var Desc3 = PSX.MakeNewDescriptor();

            Desc3.PutEnumerated(PSX.StrToID("warpStyle"), PSX.StrToID("warpStyle"), PSX.StrToID("warpNone"));
            Desc3.PutDouble(PSX.StrToID("warpValue"), 0);
            Desc3.PutDouble(PSX.StrToID("warpPerspective"), 0);
            Desc3.PutDouble(PSX.StrToID("warpPerspectiveOther"), 0);
            Desc3.PutEnumerated(PSX.StrToID("warpRotate"), (int)con.phTypeOrientation, (int)con.phEnumHorizontal);

            // Desc2
            var Desc2 = PSX.MakeNewDescriptor();

            Desc2.PutString((int)con.phKeyText, text);
            Desc2.PutObject(PSX.StrToID("warp"), PSX.StrToID("warp"), Desc3);
            Desc2.PutObject((int)con.phKeyTextClickPoint, (int)con.phClassPoint, Desc4);
            Desc2.PutEnumerated(PSX.StrToID("textGridding"), PSX.StrToID("textGridding"), (int)con.phEnumNone);
            Desc2.PutEnumerated((int)con.phKeyOrientation, (int)con.phTypeOrientation, (int)con.phEnumHorizontal);
            Desc2.PutEnumerated((int)con.phKeyAntiAlias, (int)con.phTypeAntiAlias, (int)con.phEnumAntiAliasCrisp);
            Desc2.PutList(PSX.StrToID("textShape"), List1);
            Desc2.PutList((int)con.phKeyTextStyleRange, List2);
            Desc2.PutList(PSX.StrToID("paragraphStyleRange"), List3);

            // Ref1
            var Ref1 = PSX.MakeNewReference();

            Ref1.PutClass((int)con.phClassTextLayer);

            // Desc1
            var Desc1 = PSX.MakeNewDescriptor();

            Desc1.PutReference((int)con.phKeyNull, Ref1);
            Desc1.PutObject((int)con.phKeyUsing, (int)con.phClassTextLayer, Desc2);


            int old_layer_count = LayerAPI.GetLayerCount(-1);

            // Play the event in photoshop
            PSX.PlayEvent((int)con.phEventMake, Desc1, (int)con.phDialogSilent, PSX.PlayBehavior.checkresult);

            LayerAPI.CheckLayerCount(-1, old_layer_count + 1);
        }