Note that there are some explanatory texts on larger screens.

plurals
  1. POFast method for getting pixel color?
    primarykey
    data
    text
    <p>I'm working on a Photoshop plugin using c# (with Adobe Photoshop Object Library). I'm trying to loop through all the pixels in my active document, but with the code I currently have it takes a very long time to even go through 1 row of pixels in a 256x256 file. I was wondering if there might be a better (faster) way than using ColorSampler for this? (c++ plugin?)</p> <p>This is what I currently have: (<a href="http://forums.adobe.com/thread/290211" rel="nofollow noreferrer">http://forums.adobe.com/thread/290211</a>) (<a href="https://stackoverflow.com/questions/19177693/c-sharp-equivalent-to-this-code">C# Equivalent to this code</a>)</p> <pre><code>static void Main(string[] args) { ps.Application app = new ps.Application(); app.Preferences.RulerUnits = ps.PsUnits.psPixels; ps.Document activeDoc = app.ActiveDocument; double docWidth = activeDoc.Width; double docHeight = activeDoc.Height; double xPos = 0.0D; double yPos = 0.0D; activeDoc.ColorSamplers.RemoveAll(); var pixelLoc = new object[] { 0.0D, 0.0D }; ps.ColorSampler myColorSampler = activeDoc.ColorSamplers.Add(pixelLoc); var stopwatch = Stopwatch.StartNew(); ps.SolidColor myColor; double red; double green; double blue; for (xPos = 0.0D; xPos &lt;=docWidth - 1; xPos++) { myColor = myColorSampler.Color; red = myColor.RGB.Red; green = myColor.RGB.Green; blue = myColor.RGB.Blue; pixelLoc[0] = xPos; myColorSampler.Move(pixelLoc); } Console.WriteLine(stopwatch.ElapsedMilliseconds); //11000 ms for 1 row of 256 pixels Console.ReadLine(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload