public void OpenWithConstraints(ref ps.ApplicationClass app, ref ps.Document doc, FileInfo file, double width, double height) { // Set EPS openning options // Open with Width constraint ps.EPSOpenOptionsClass EpsOpenOptsWidth = new ps.EPSOpenOptionsClass(); EpsOpenOptsWidth.AntiAlias = _antiAlias; EpsOpenOptsWidth.ConstrainProportions = _constrainProportions; EpsOpenOptsWidth.Mode = _mode; EpsOpenOptsWidth.Resolution = _resolution; EpsOpenOptsWidth.Width = PsTools.GetPixelUnit(width, _resolution); // Open with Height constraint ps.EPSOpenOptionsClass EpsOpenOptsHeight = new ps.EPSOpenOptionsClass(); EpsOpenOptsHeight.AntiAlias = _antiAlias; EpsOpenOptsHeight.ConstrainProportions = _constrainProportions; EpsOpenOptsHeight.Mode = _mode; EpsOpenOptsHeight.Resolution = _resolution; EpsOpenOptsHeight.Height = PsTools.GetPixelUnit(height, _resolution); doc = app.Open(file.FullName, EpsOpenOptsWidth); if (doc.Height > height) { Close(ref doc); doc = app.Open(file.FullName, EpsOpenOptsHeight); } }
/// <summary> /// Determine if the background of the document is transparent /// </summary> /// <param name="app">Photoshop Application Object</param> /// <param name="doc">Photoshop Document Object</param> /// <returns>if document background is transparent </returns> public static bool IsTransparent(ref ps.ApplicationClass app, ref ps.Document doc) { //Make Transparent pixels as selection var desc = new ps.ActionDescriptorClass(); var ref1 = new ps.ActionReferenceClass(); ref1.PutProperty((int)cst.phClassChannel, (int)cst.phKeySelection); desc.PutReference((int)cst.phClassNull, ref1); var ref2 = new ps.ActionReferenceClass(); ref2.PutEnumerated((int)cst.phClassChannel, (int)cst.phClassChannel, (int)cst.phEnumTransparency); desc.PutReference((int)cst.phKey_Source, ref2); app.ExecuteAction((int)cst.phEventSet, desc, ps.PsDialogModes.psDisplayNoDialogs); // Verify if the Selection is consistent if (doc.Selection.Solid) { Deselect(ref doc);; return(false); } else { Deselect(ref doc); return(true); } }
/// <summary> /// Set a color sampler to the specified localization /// </summary> /// <param name="app">Photoshop Application object</param> /// <param name="doc">Photoshop Document object</param> /// <param name="x">X-Axis color sampler localization</param> /// <param name="y">Y-Axis color sampler localization</param> public static void SetColorSampler(ref ps.ApplicationClass app, ref ps.Document doc, int x, int y) { // Code from action listener plugin int idMk = (int)cst.phEventMake; var desc3 = new ps.ActionDescriptorClass(); int idnull = (int)cst.phClassNull; var ref1 = new ps.ActionReferenceClass(); int idClSm = (int)cst.phClassColorSampler; ref1.PutClass(idClSm); desc3.PutReference(idnull, ref1); int idPstn = (int)cst.phKeyPosition; var desc4 = new ps.ActionDescriptorClass(); int idHrzn = (int)cst.phEnumHorizontal; int idPxl = (int)cst.phUnitPixels; desc4.PutUnitDouble(idHrzn, idPxl, (double)x); int idVrtc = (int)cst.phEnumVertical; desc4.PutUnitDouble(idVrtc, idPxl, (double)y); int idPnt = (int)cst.phClassPoint; desc3.PutObject(idPstn, idPnt, desc4); app.ExecuteAction(idMk, desc3, ps.PsDialogModes.psDisplayNoDialogs); }
public void SetBackGroundTransparent(ref ps.ApplicationClass app, ref ps.Document doc) { bool isTransparent = PsTools.IsTransparent(ref app, ref doc); if (!isTransparent) { doc.ArtLayers[0].Name = "Background"; doc.LayerComps[0].Name = "Background"; PsTools.SetBckgTransparentAction(ref app); } }
/// <summary> /// Magic Wand selection /// </summary> /// <param name="app">Photoshop Application Object</param> /// <param name="x">x-Axis pixel source selection</param> /// <param name="y">y-Axis pixel source selection</param> /// <param name="tolerance"> Selection tolerance</param> /// <param name="antiAlias"> Anti-Alias option</param> /// <param name="contiguous"></param> /// <param name="mergedLayer"></param> public static void MagicWand(ps.ApplicationClass app, int x, int y, int tolerance = 32, bool antiAlias = true, bool contiguous = false, bool mergedLayer = false) { // Action recorded on photoshop and transcripted by the Action Listener script // This code is the result of the Action Listener script ps.ActionDescriptorClass desc = new ps.ActionDescriptorClass(); ps.ActionReferenceClass refe = new ps.ActionReferenceClass(); refe.PutProperty((int)cst.phClassChannel, (int)cst.phKeySelection); desc.PutReference((int)cst.phClassNull, refe); ps.ActionDescriptorClass positionDesc = new ps.ActionDescriptorClass(); positionDesc.PutUnitDouble((int)cst.phEnumHorizontal, (int)cst.phUnitDistance, x); positionDesc.PutUnitDouble((int)cst.phEnumVertical, (int)cst.phUnitDistance, y); desc.PutObject((int)cst.phKey_Source, (int)cst.phClassPoint, positionDesc); desc.PutInteger((int)cst.phKeyTolerance, tolerance); // tolerance desc.PutBoolean((int)cst.phEnumMerged, mergedLayer); // sample all layers desc.PutBoolean((int)cst.phKeyContiguous, contiguous); // contiguous desc.PutBoolean((int)cst.phClassAntiAliasedPICTAcquire, antiAlias); // anti-alias app.ExecuteAction((int)cst.phEventSet, desc, ps.PsDialogModes.psDisplayNoDialogs); }
public void OpenWithConstraints(ref ps.ApplicationClass app, ref ps.Document doc, FileInfo file, double width, double height) { //Width Constraint ps.PDFOpenOptionsClass PdfOpenOptsWidth = new ps.PDFOpenOptionsClass(); PdfOpenOptsWidth.AntiAlias = _antiAlias; PdfOpenOptsWidth.BitsPerChannel = _bitsPerChannel; PdfOpenOptsWidth.ConstrainProportions = _constrainProportions; PdfOpenOptsWidth.SuppressWarnings = _suppressWarnings; PdfOpenOptsWidth.CropPage = _cropPage; PdfOpenOptsWidth.Mode = _mode; PdfOpenOptsWidth.Page = _page; PdfOpenOptsWidth.UsePageNumber = _usePageNumber; PdfOpenOptsWidth.Resolution = _resolution; PdfOpenOptsWidth.Width = PsTools.GetPixelUnit(width, _resolution); //Height Constraint ps.PDFOpenOptionsClass PdfOpenOptsHeight = new ps.PDFOpenOptionsClass(); PdfOpenOptsHeight.AntiAlias = _antiAlias; PdfOpenOptsHeight.BitsPerChannel = _bitsPerChannel; PdfOpenOptsHeight.ConstrainProportions = _constrainProportions; PdfOpenOptsHeight.SuppressWarnings = _suppressWarnings; PdfOpenOptsHeight.CropPage = _cropPage; PdfOpenOptsHeight.Mode = _mode; PdfOpenOptsWidth.UsePageNumber = _usePageNumber; PdfOpenOptsHeight.Page = _page; PdfOpenOptsHeight.Resolution = _resolution; PdfOpenOptsHeight.Height = PsTools.GetPixelUnit(height, _resolution); //Open the file doc = app.Open(file.FullName, PdfOpenOptsWidth); if (doc.Height > height) { Close(ref doc); //Open the file doc = app.Open(file.FullName, PdfOpenOptsHeight); } }
public void SetBackGroundTransparent(ref ps.ApplicationClass app, ref ps.Document doc) { _def.SetBackGroundTransparent(ref app, ref doc); }
public void SetUnits(ref ps.ApplicationClass app, ref ps.Document doc) { _def.SetUnits(ref app, ref doc); }
public void OpenWithConstraints(ref ps.ApplicationClass app, ref ps.Document doc, FileInfo file, double width, double height) { _def.OpenWithConstraints(ref app, ref doc, file, width, height); }
public void OpenWithConstraints(ref ps.ApplicationClass app, ref ps.Document doc, FileInfo file, double width, double height) { //Open any bitmap image doc = app.Open(file.FullName); ResizeImageWithConstraints(ref doc, width, height); }
public void SetUnits(ref ps.ApplicationClass app, ref ps.Document doc) { app.Preferences.RulerUnits = _rulerUnits; app.Preferences.TypeUnits = _typeUnits; }
/// <summary> /// Set transparent the background of the active document /// </summary> /// <param name="app">Photoshop Application object</param> public static void SetBckgTransparentAction(ref ps.ApplicationClass app) { // Call action already stored in photoshop app.DoAction(_transparentBckgActionName, _transparentBckgActionFolder); }