Page 1 of 1

Extract RGB from buf.puixels

PostPosted: Sep 9, 2003 @ 2:38pm
by Maoz
How can i extract the blue value for example from the RGB of a specific pixel.

//After fetching the pixel
uint16_t p = lockInfo.pixels[y * nPitch + x];

// What should i do here?

Thanks Maoz.

PostPosted: Sep 9, 2003 @ 6:15pm
by Guest
when you have the 16 bit pixel value,
as in your code, you probably have a 565 format meaning 5 bits red, 6 bits green, 5 bits blue,
so do a bitwise 'and = &' operation on the pixel to remove the R & G component

eg: uint16_t pix = buffer[...];
int blueval = pix & 0x1F; // 0x1F = binary 11111

PostPosted: Sep 9, 2003 @ 9:40pm
by fast_rx