public static void CreateDocument(int pixelwidth, int pixelheight, int ppi, int fill, int mode, string name) { System.Diagnostics.Debug.Assert(pixelwidth > 0); System.Diagnostics.Debug.Assert(pixelheight > 0); System.Diagnostics.Debug.Assert(ppi > 0); //PSX.CheckEnum( mode, (int) con.phClassRGBColorMode ); PSX.CheckEnum(fill, (int)con.phEnumTransparent, (int)con.phEnumBackgroundColor, (int)con.phEnumWhite); // Creates a new document // Create Desc2 var Desc2 = PSX.MakeNewDescriptor(); Desc2.PutString((int)con.phKeyName, name); Desc2.PutClass((int)con.phKeyMode, mode); Desc2.PutUnitDouble((int)con.phKeyWidth, (int)con.phUnitDistance, pixelwidth); Desc2.PutUnitDouble((int)con.phKeyHeight, (int)con.phUnitDistance, pixelheight); Desc2.PutUnitDouble((int)con.phKeyResolution, (int)con.phUnitDensity, ppi); Desc2.PutEnumerated((int)con.phKeyFill, (int)con.phTypeFill, fill); // Create Desc1 PhotoshopTypeLibrary.IActionDescriptor Desc1 = PSX.MakeNewDescriptor(); Desc1.PutObject((int)con.phKeyNew, (int)con.phClassDocument, Desc2); int old_count = DocumentAPI.GetDocumentCount(); // Play the Event Into Photoshop PSX.PlayEvent((int)con.phEventMake, Desc1, (int)con.phDialogSilent, PSX.PlayBehavior.checknone); DocumentAPI.CheckDocumentCount(old_count + 1); }
public static void GetColorEx(int color_id, out int color_class_id, ref double[] v) { PhotoshopTypeLibrary.IActionDescriptor desc, desc2; PSX.CheckEnum(color_id, (int)con.phKeyForegroundColor, (int)con.phKeyBackgroundColor); desc = PSX.get_descriptor_to_object_property_by_index((int)con.phClassApplication, -1, color_id); int actual_color_class_id; desc.GetObject((int)con.phKeyForegroundColor, out actual_color_class_id, out desc2); if (actual_color_class_id == (int)con.phClassRGBColor) { color_class_id = (int)con.phClassRGBColor; v[0] = (double)PSX.get_value_from_descriptor(desc2, (int)con.phKeyRed); v[1] = (double)PSX.get_value_from_descriptor(desc2, (int)con.phKeyGreen); v[2] = (double)PSX.get_value_from_descriptor(desc2, (int)con.phKeyBlue); v[3] = 0; } else { string msg = string.Format("Did not understand color type returned"); var e = new Photoshop6OM.PhotoshoProxyError(msg); throw e; } }
static public void CreateGradientFillLayer(string layer_name, int gradient_type, double angle, PhotoshopTypeLibrary.IActionDescriptor [] opacity_stops, PhotoshopTypeLibrary.IActionDescriptor [] color_stops) { PSX.CheckRange(angle, 0, 360); PSX.CheckEnum(gradient_type, (int)con.phEnumLinear, (int)con.phEnumRadial); string gradient_name = "Custom Gradient"; // List2 var List2 = PSX.MakeNewList(); PSX.AddDescriptorsToList(List2, opacity_stops, (int)con.phClassTransparencyStop); // List1 var List1 = PSX.MakeNewList(); PSX.AddDescriptorsToList(List1, color_stops, (int)con.phClassColorStop); // Desc4 var Desc4 = PSX.MakeNewDescriptor(); Desc4.PutString((int)con.phKeyName, gradient_name); Desc4.PutEnumerated(1198679110, (int)con.phTypeGradientForm, (int)con.phEnumCustomStops); Desc4.PutDouble((int)con.phKeyInterfaceIconFrameDimmed, 4096); Desc4.PutList((int)con.phKeyColors, List1); Desc4.PutList((int)con.phKeyTransparency, List2); // Desc3 var Desc3 = PSX.MakeNewDescriptor(); Desc3.PutUnitDouble((int)con.phKeyAngle, (int)con.phUnitAngle, angle); Desc3.PutEnumerated((int)con.phKeyType, (int)con.phTypeGradientType, gradient_type); Desc3.PutObject((int)con.phKeyGradient, (int)con.phClassGradient, Desc4); // Desc2 var Desc2 = PSX.MakeNewDescriptor(); Desc2.PutString((int)con.phKeyName, layer_name); Desc2.PutObject((int)con.phKeyType, PSX.StrToID("gradientLayer"), Desc3); // Ref1 var Ref1 = PSX.MakeNewReference(); Ref1.PutClass(PSX.StrToID("contentLayer")); // Desc1 var Desc1 = PSX.MakeNewDescriptor(); Desc1.PutReference((int)con.phKeyNull, Ref1); Desc1.PutObject((int)con.phKeyUsing, PSX.StrToID("contentLayer"), Desc2); // Play the event in photoshop PSX.PlayEvent((int)con.phEventMake, Desc1, (int)con.phDialogSilent, PSX.PlayBehavior.checkresult); }
public static void AddNoise(int distortion, double amount, int monochromatic) { PSX.CheckEnum(distortion, (int)con.phEnumUniformDistribution, (int)con.phEnumGaussianDistribution); PSX.CheckRange(amount, 0, 400); PSX.CheckEnum(monochromatic, PSX.TRUE, PSX.FALSE); // Desc1 var Desc1 = PSX.MakeNewDescriptor(); Desc1.PutEnumerated((int)con.phKeyDistortion, (int)con.phTypeDistribution, distortion); Desc1.PutUnitDouble((int)con.phKeyNoise, (int)con.phUnitPercent, amount); Desc1.PutBoolean((int)con.phKeyMonochromatic, monochromatic); // Play the event in photoshop PSX.PlayEvent((int)con.phEventAddNoise, Desc1, (int)con.phDialogSilent, PSX.PlayBehavior.checkresult); }
public static void __SetAppColor(int color_id, PhotoshopTypeLibrary.IActionDescriptor RGBCOLORDESC) { PSX.CheckEnum(color_id, (int)con.phKeyForegroundColor, (int)con.phKeyBackgroundColor); // Ref1 var Ref1 = PSX.MakeNewReference(); Ref1.PutProperty((int)con.phClassColor, color_id); // Desc1 var Desc1 = PSX.MakeNewDescriptor(); Desc1.PutReference((int)con.phKeyNull, Ref1); Desc1.PutObject((int)con.phKeyTo, (int)con.phClassRGBColor, RGBCOLORDESC); // Play the event in photoshop PSX.PlayEvent((int)con.phEventSet, Desc1, (int)con.phDialogSilent, PSX.PlayBehavior.checknone); }
public static void SaveCopyAsPNG(string filename, int interlace) { _start_save(filename); PSX.CheckEnum(interlace, (int)con.phEnumPNGInterlaceNone, (int)con.phEnumPNGInterlaceAdam7); // Desc2 var Desc2 = PSX.MakeNewDescriptor(); Desc2.PutEnumerated((int)con.phKeyPNGInterlaceType, (int)con.phTypePNGInterlaceType, interlace); Desc2.PutEnumerated((int)con.phKeyPNGFilter, (int)con.phTypePNGFilter, (int)con.phEnumPNGFilterAdaptive); // Desc1 var Desc1 = PSX.MakeNewDescriptor(); Desc1.PutObject((int)con.phKeyAs, (int)con.phClassPNGFormat, Desc2); Desc1.PutPath((int)con.phKeyIn, filename); Desc1.PutBoolean((int)con.phKeyCopy, PSX.TRUE); _end_save(filename, Desc1); }