Exemple #1
0
        /// <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);
        }
Exemple #2
0
        /// <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);
        }