/// <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 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); } }
public void Save(ref ps.Document doc, FileInfo file) { ps.ExportOptionsIllustratorClass SaveOpts = new ps.ExportOptionsIllustratorClass(); SaveOpts.Path = _path; doc.Export(file.FullName, ps.PsExportType.psIllustratorPaths, SaveOpts); }
/// <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); } }
public void ResizeImageWithConstraints(ref ps.Document doc, double width, double height) { if (doc.Width / doc.Height <= width / height) { doc.ResizeImage(Height: height, ResampleMethod: ps.PsPDFResampleType.psPDFBicubic); } else { doc.ResizeImage(Width: width, ResampleMethod: ps.PsPDFResampleType.psPDFBicubic); } }
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); } }
public void Save(ref ps.Document doc, FileInfo file) { // Save png for web format ps.EPSSaveOptionsClass SaveOpts = new ps.EPSSaveOptionsClass(); SaveOpts.Preview = _preview; SaveOpts.VectorData = _vectorData; SaveOpts.Interpolation = true; SaveOpts.Encoding = ps.PsSaveEncoding.psJPEGMedium; doc.SaveAs(file.FullName, SaveOpts, true, ps.PsExtensionType.psLowercase); }
public void Save(ref ps.Document doc, FileInfo file) { // Save png for web format ps.TiffSaveOptionsClass SaveOpts = new ps.TiffSaveOptionsClass(); SaveOpts.AlphaChannels = _alphaChannel; SaveOpts.Annotations = _annotations; SaveOpts.ByteOrder = _byteOrder; SaveOpts.JPEGQuality = _jpgQuality; SaveOpts.LayerCompression = _layerCompression; SaveOpts.Layers = _layers; SaveOpts.SpotColors = _spotColors; SaveOpts.Transparency = _transparency; doc.SaveAs(file.FullName, SaveOpts, true, ps.PsExtensionType.psLowercase); }
private const int _quality = 70; // Percentage quality of the png generated public void Save(ref ps.Document doc, FileInfo file) { // Save png for web format ps.ExportOptionsSaveForWebClass SaveOpts = new ps.ExportOptionsSaveForWebClass(); SaveOpts.Format = _format; SaveOpts.Interlaced = _interlaced; ps.RGBColorClass _rgbColor = new ps.RGBColorClass(); _rgbColor.Red = 255; _rgbColor.Green = 255; _rgbColor.Blue = 255; SaveOpts.MatteColor = _rgbColor; doc.Export(file.FullName, ps.PsExportType.psSaveForWeb, SaveOpts); }
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 Close(ref ps.Document doc) { _def.Close(ref doc); }
public void Save(ref ps.Document doc, IFileSaver fileSaver, FileInfo file) { _def.Save(ref doc, fileSaver, file); }
public void SetBackGroundTransparent(ref ps.ApplicationClass app, ref ps.Document doc) { _def.SetBackGroundTransparent(ref app, ref doc); }
public void ExtendCanvas(ref ps.Document doc, double width, double height) { _def.ExtendCanvas(ref doc, width, height); }
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); }
/// <summary> /// Deslect current document selection /// </summary> /// <param name="doc">Photoshop Document Object</param> public static void Deselect(ref ps.Document doc) { doc.Selection.Deselect(); }
/// <summary> /// Delete the current selection /// </summary> /// <param name="doc">Photoshop Document Object</param> public static void DeleteSelection(ref ps.Document doc) { doc.Selection.Clear(); }
public void Close(ref ps.Document doc) { doc.Close(ps.PsSaveOptions.psDoNotSaveChanges); }
public void ExtendCanvas(ref ps.Document doc, double width, double height) { doc.ResizeCanvas(width, height, ps.PsAnchorPosition.psMiddleCenter); }
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; }