c++ - Get RGB Channels From Pixel Value Without Any Library -
get rgb channels pixel value without library
i`m trying rgb channels of each pixel read image. use getchar reading each byte image. after little search did on web found on bmp example colors data start after 36 byte, know each channle 8 bit , whole rgb 8 bit of red, 8 bit of green , 8 bit of blue. question how extract them pixel value?
example:
pixel = getchar(image);
what can extract channels? in addition saw example on java dont know how implement on c++ :
int rgb[] = new int[] { (argb >> 16) & 0xff, //red (argb >> 8) & 0xff, //green (argb ) & 0xff //blue };
i guess argb "pixel" var mentioned before.
thanks.
assuming it's encoded abgr , have 1 integer value per pixel, should trick:
int r = color & 0xff; int g = (color >> 8) & 0xff; int b = (color >> 16) & 0xff; int = (color >> 24) & 0xff;
Comments
Post a Comment