FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   How can I get the R, G or B from a color datatype
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: How can I get the R, G or B from a color datatype  (Read 1914 times)
javito

jburong Email
How can I get the R, G or B from a color datatype
« on: Aug 13th, 2003, 8:16pm »

Hi I?m trying to get the R, G or B value as a integer from a single pixel of a image, how can i get it?
 
I need to get only one of these values and store as a integer.
 
Thank you very much and sorry about my english..
 

Javi Burón
arielm

WWW
Re: How can I get the R, G or B from a color datat
« Reply #1 on: Aug 13th, 2003, 9:05pm »

not tested but should work:
 
Code:

int p = pixels[1234];  // p is holding something like #00ffc033
 
int r = (p >> 16) & 0x000000ff;
int g = (p >> 8) & 0x000000ff;
int b = p & 0x000000ff;
 

Ariel Malka | www.chronotext.org
REAS


WWW
Re: How can I get the R, G or B from a color datat
« Reply #2 on: Aug 14th, 2003, 6:25pm »

The simple way to do this uses the functions red(), blue() and green(). They are documented here:
 
http://www.proce55ing.net/reference/red_.html
http://www.proce55ing.net/reference/blue_.html
http://www.proce55ing.net/reference/green_.html
 
javito

jburong Email
Re: How can I get the R, G or B from a color datat
« Reply #3 on: Aug 14th, 2003, 9:33pm »

Thank you very much!!!!!
 

Javi Burón
Pages: 1 

« Previous topic | Next topic »