Archived

This topic is now archived and is closed to further replies.

Help with Pixel from Bitmap

This topic is 5745 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ide like to know, after i load a bitmap from file, how could i go about obtaining the specific color of a precise pixel (x,y) if the bitmap is not going to be shown on the screen. This is a monachrome bitmap. thanks - ness

Share this post


Link to post
Share on other sites
First, you have to find the the picture data field. It should probably be an array of chars. You then need to use masking to extract each individual pixel out of a char.


    
char mask1 = 0x01;
char mask2 = 0x02;
char mask3 = 0x04;
char mask4 = 0x08;
char mask5 = 0x10;
char mask6 = 0x20;
char mask7 = 0x40;
char mask8 = 0x80;


if you want to access the first bit, type this.


int newbit = (PictureData[0] & mask1);


If newbit = 0, then the pixel is black, if newbit is any number other than 0, then the pixel is white.

Hope that helped.

[edited by - Forcas on March 20, 2002 12:02:40 AM]

Share this post


Link to post
Share on other sites