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; } }
public static void DuplicateDocument(string new_name, bool merge_layers) { System.Diagnostics.Debug.Assert(new_name.Length > 0); // Ref1 var Ref1 = PSX.MakeNewReference(); Ref1.PutEnumerated((int)con.phClassDocument, (int)con.phTypeOrdinal, (int)con.phEnumFirst); // Desc1 var Desc1 = PSX.MakeNewDescriptor(); Desc1.PutReference((int)con.phKeyNull, Ref1); Desc1.PutString((int)con.phKeyName, new_name); if (merge_layers) { Desc1.PutBoolean((int)con.phKeyMerged, PSX.TRUE); } else { Desc1.PutBoolean((int)con.phKeyMerged, PSX.FALSE); } int old_count = DocumentAPI.GetDocumentCount(); // Play the event in photoshop PSX.PlayEvent((int)con.phEventDuplicate, Desc1, (int)con.phDialogSilent, PSX.PlayBehavior.checkresult); DocumentAPI.CheckDocumentCount(old_count + 1); }
public static void eventSave() { var Desc1 = PSX.MakeNewDescriptor(); // Play the event in photoshop PSX.PlayEvent((int)con.phEventSave, Desc1, (int)con.phDialogSilent, PSX.PlayBehavior.checknone); }
public static System.Collections.ArrayList query_object_properties(int object_classid, int [] prop_ids) { int start; int end; // rowset will store the results var rowset = new System.Collections.ArrayList(); // Find out how many objects there are PSX.get_range_from_object_collection(object_classid, out start, out end); // Loop through each object in its collection for (int index = start; index < end; index++) { // Get the properties for this object // and then add it to the result set System.Collections.ArrayList row = PSX.get_values_from_object(object_classid, index, prop_ids); rowset.Add(row); } // Done, now return the result return(rowset); }
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 CreateSolidColorFillLayer(string layer_name, int red, int green, int blue) { // Desc4 var Desc4 = PSX.CreateDescriptorForRGBColor(red, green, blue); // Desc3 var Desc3 = PSX.MakeNewDescriptor(); Desc3.PutObject((int)con.phKeyColor, (int)con.phClassRGBColor, Desc4); // Desc2 var Desc2 = PSX.MakeNewDescriptor(); Desc2.PutString((int)con.phKeyName, layer_name); Desc2.PutObject((int)con.phKeyType, PSX.StrToID("solidColorLayer"), 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 InvertSelection( ) { var Desc1 = PSX.MakeNewDescriptor(); // Play the event in photoshop PSX.PlayEvent((int)con.phEventInverse, Desc1, (int)con.phDialogSilent, PSX.PlayBehavior.checkresult); }
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); }
public static void Paste() { /* * System.Windows.Forms.IDataObject ido = System.Windows.Forms.Clipboard.GetDataObject(); * * if (ido!=null) * { * * * string [] formats = ido.GetFormats(); * foreach (string s in formats) * { * System.Console.WriteLine( "FMT {0}",s ); * } * } * */ // Desc1 var Desc1 = PSX.MakeNewDescriptor(); Desc1.PutEnumerated((int)con.phKeyAntiAlias, (int)con.phTypeAntiAlias, (int)con.phEnumAntiAliasNone); // Play the event in photoshop PSX.PlayEvent((int)con.phEventPaste, Desc1, (int)con.phDialogSilent, PSX.PlayBehavior.checkresult); }
static public PhotoshopTypeLibrary.IActionDescriptor CreateOpacityStop(double percent, int location, int midpoint) { var OpacityDesc = PSX.MakeNewDescriptor(); OpacityDesc.PutUnitDouble((int)con.phKeyOpacity, (int)con.phUnitPercent, percent); OpacityDesc.PutInteger((int)con.phKeyLocation, location); OpacityDesc.PutInteger((int)con.phKeyMidpoint, midpoint); return(OpacityDesc); }
public static int GetDirtyFlag(int doc_index) { /// /// <summary> /// Returns the title of document with given doc)index /// </summary> /// return((int)PSX.get_value_from_object((int)con.phClassDocument, doc_index, (int)con.phKeyIsDirty)); }
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); }
public static void get_range_from_object_collection(int object_id, out int start, out int end) { // Given an object_id returns the number of objects of that type contained int count = PSX.get_count_from_object_collection(object_id); start = 1; end = count + 1; }
public static PhotoshopTypeLibrary.IActionDescriptor CreateDescriptorForRGBColor(System.Drawing.Color C) { var Desc = PSX.MakeNewDescriptor(); Desc.PutDouble((int)con.phKeyRed, C.R); Desc.PutDouble((int)con.phKeyGrain, C.G); Desc.PutDouble((int)con.phKeyBlue, C.B); return(Desc); }
public static PhotoshopTypeLibrary.IActionDescriptor CreateDescriptorForRGBColor(int red, int green, int blue) { var Desc = PSX.MakeNewDescriptor(); Desc.PutDouble((int)con.phKeyRed, red); Desc.PutDouble((int)con.phKeyGrain, green); Desc.PutDouble((int)con.phKeyBlue, blue); return(Desc); }
public static string GetTitle(int doc_index) { /// /// <summary> /// Returns the title of document with given doc)index /// </summary> /// return((string)PSX.get_value_from_object((int)con.phClassDocument, doc_index, (int)con.phKeyTitle)); }
static public PhotoshopTypeLibrary.IActionDescriptor CreateColorStop(System.Drawing.Color c, int location, int midpoint) { var Desc5 = PSX.MakeNewDescriptor(); Desc5.PutObject((int)con.phKeyColor, (int)con.phClassRGBColor, PSX.CreateDescriptorForRGBColor(c)); Desc5.PutEnumerated((int)con.phKeyType, (int)con.phTypeColorStopType, (int)con.phEnumUserStop); Desc5.PutInteger((int)con.phKeyLocation, location); Desc5.PutInteger((int)con.phKeyMidpoint, midpoint); return(Desc5); }
public static PhotoshopTypeLibrary.IActionDescriptor CreateDescriptorForRectangle(int left, int top, int right, int bottom) { var Desc = PSX.MakeNewDescriptor(); Desc.PutUnitDouble((int)con.phKeyTop, (int)con.phUnitDistance, top); Desc.PutUnitDouble((int)con.phKeyLeft, (int)con.phUnitDistance, left); Desc.PutUnitDouble((int)con.phKeyBottom, (int)con.phUnitDistance, bottom); Desc.PutUnitDouble((int)con.phKeyRight, (int)con.phUnitDistance, right); return(Desc); }
public static int GetLayerCount(int doc_index) { /// /// <summary> /// Returns the number of documents open /// </summary> /// return((int)PSX.get_value_from_object((int)con.phClassDocument, doc_index, (int)con.phKeyNumberOfLayers)); }
public static int GetDocumentCount() { /// /// <summary> /// Returns the number of documents open /// </summary> /// return((int)PSX.get_value_from_object((int)con.phClassApplication, -1, (int)con.phKeyNumberOfDocuments)); }
public static PhotoshopTypeLibrary.IActionDescriptor CreateDescriptorForRectangle(System.Drawing.Rectangle r) { var Desc = PSX.MakeNewDescriptor(); Desc.PutUnitDouble((int)con.phKeyTop, (int)con.phUnitDistance, r.Top); Desc.PutUnitDouble((int)con.phKeyLeft, (int)con.phUnitDistance, r.Left); Desc.PutUnitDouble((int)con.phKeyBottom, (int)con.phUnitDistance, r.Bottom); Desc.PutUnitDouble((int)con.phKeyRight, (int)con.phUnitDistance, r.Right); return(Desc); }
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 int get_type_from_descriptor(PhotoshopTypeLibrary.IActionDescriptor desc, int prop_id) { // Returns the type for a property stored in a descriptor int v; System.Diagnostics.Debug.Assert(desc != null); System.Diagnostics.Debug.Assert(PSX.desc_has_key(desc, prop_id)); desc.GetType(prop_id, out v); return(v); }
public static void GaussianBlur(double radius) { PSX.CheckRange(radius, 0, 250); // Desc1 var Desc1 = PSX.MakeNewDescriptor(); Desc1.PutUnitDouble((int)con.phKeyRadius, (int)con.phUnitPixels, radius); // Play the event in photoshop PSX.PlayEvent((int)con.phEventGaussianBlur, Desc1, (int)con.phDialogSilent, PSX.PlayBehavior.checkresult); }
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); }
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); }
public static void SetColorEx(int color_id, int color_class, double [] v) { var Desc2 = PSX.MakeNewDescriptor(); if (color_class == (int)con.phClassHSBColor) { Desc2.PutUnitDouble((int)con.phKeyHue, (int)con.phUnitAngle, v[0]); Desc2.PutDouble((int)con.phKeySaturation, v[1]); Desc2.PutDouble((int)con.phKeyBrightness, v[2]); } else if (color_class == (int)con.phClassRGBColor) { Desc2.PutDouble((int)con.phKeyRed, v[0]); Desc2.PutDouble((int)con.phKeyGrain, v[1]); Desc2.PutDouble((int)con.phKeyBlue, v[2]); } else if (color_class == (int)con.phClassLabColor) { Desc2.PutDouble((int)con.phKeyLuminance, v[0]); Desc2.PutDouble((int)con.phKeyA, v[1]); Desc2.PutDouble((int)con.phKeyB, v[2]); } else if (color_class == (int)con.phClassCMYKColor) { Desc2.PutDouble((int)con.phKeyCyan, v[0]); Desc2.PutDouble((int)con.phKeyMagenta, v[1]); Desc2.PutDouble((int)con.phKeyYellow, v[2]); Desc2.PutDouble((int)con.phKeyBlack, v[3]); } else { var e = new Photoshop6OM.PhotoshoProxyError("Improper Color Class"); throw e; } var Ref1 = PSX.MakeNewReference(); Ref1.PutProperty((int)con.phClassColor, color_id); var Desc1 = PSX.MakeNewDescriptor(); Desc1.PutReference((int)con.phKeyNull, Ref1); Desc1.PutObject((int)con.phKeyTo, color_class, Desc2); // ---------------------------------------- // Play the event // ---------------------------------------- PSX.PlayEvent((int)con.phEventSet, 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 SelectLayer( ) { // Ref1 var Ref1 = PSX.MakeNewReference(); Ref1.PutEnumerated((int)con.phClassChannel, (int)con.phTypeChannel, (int)con.phEnumMask); // Desc1 var Desc1 = PSX.MakeNewDescriptor(); Desc1.PutReference((int)con.phKeyNull, Ref1); // Play the event in photoshop PSX.PlayEvent((int)con.phEventSelect, Desc1, (int)con.phDialogSilent, PSX.PlayBehavior.checknone); }
public static System.Collections.ArrayList GetDocumentProperties(int doc_index, int [] prop_ids) { /// /// <summary> /// Returns the specified document properties /// /// </summary> /// System.Collections.ArrayList values; values = PSX.get_values_from_object((int)con.phClassDocument, doc_index, prop_ids); return(values); }