Getpixel returns the color of the pixel in c++. Is there an equivalent in Processing..? if not is there any mechanism to get pixel details? Thankyou in adv!
"Getpixel returns the color of the pixel in c++"
Although the intent of the function is clear, I doubt there is such function in standard C++. You can find it tied to some OS (Windows / Linux / MacOS) and / or some graphical manager (Gtk+ / KDE, etc.) or library (Qt / Cairo / etc.).
Comments
the get(x,y) method will get the pixel color from the position [x,y]
Thankx quark and GoToLoop! this was the quickest reply i ever got to my question! thanks a lot!
"Getpixel returns the color of the pixel in c++"
Although the intent of the function is clear, I doubt there is such function in standard C++. You can find it tied to some OS (Windows / Linux / MacOS) and / or some graphical manager (Gtk+ / KDE, etc.) or library (Qt / Cairo / etc.).
i tried pixel[]... what exactly does it contain? int or a variable of type color?
Pixel [] is an array of
int
elments each pixel/int is 4 bytes long so 32 bitsThese are used to create four 8-bit 'channels'
Alpha A bits 24-31
Red R bits 16-23
Green bits 8 -15
Blue bits 0-7
Thia colour scheme is refered to ARGB
Alpha is level of transparency / opaqueness
Google should give you more detailed info on 32 bit ARGB
i thought int was 2byte! can i extract R,G and B values?
short
&char
are 2 bytes (16 bits). Read aboutcolor
datatype:https://processing.org/reference/color_datatype.html
Got it! done! thnakx!
You can get the individual channels with bitmasks following the formatting quark mentioned. For example, to get red you could do this:
int red = pixels[i]&0xff0000;