We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › get() colors from offscreen image - can it be done
Page Index Toggle Pages: 1
get() colors from offscreen image - can it be done (Read 440 times)
get() colors from offscreen image - can it be done
Mar 3rd, 2010, 6:52am
 
Is it possible, using pixels[] or get(), to read color data from an image that is not displayed in the window?
I am trying to color shapes using colors from an image, but I do not want the image visible on screen.

i.e, if I have a window with size - 100x100,
and a seedImage with dimensions 100x100 (e.g. a vertical gradient from white to black)
how can I do the following:

for (int x = 0; x<width; x+=10){
 for (int y = 0; y<height; y+=10){
   fill( seedImage.get(x,y) );
   rect(x, y, 10, 10);
 }
}

the reason I don't want the image visible is, every time draw runs, get() finds a rectangle already drawn there, samples its color, and returns the color of the rectangle instead of the original image below.
Re: get() colors from offscreen image - can it be done
Reply #1 - Mar 3rd, 2010, 7:22am
 
http://processing.org/reference/PImage.html

you can create a PImage without displaying it and then use the get() method in there, pretty much using the code you have.
Re: get() colors from offscreen image - can it be done
Reply #2 - Mar 3rd, 2010, 7:57am
 
I feel like such a booger Smiley
Thank you so much!
Page Index Toggle Pages: 1