• ### Announcements

#### Archived

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

# Help with Pixel from Bitmap

## Recommended Posts

nessy    122
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 on other sites
Muzlack    127
I''m not sure since I haven''t done this in a while, but all I think you have to do is Lock() the surface and do
int color=[x+y*ddsd.lPitch];

prolly not int, but I hope you get the idea

Sponge Factory
--Muzlack

##### Share on other sites
Forcas    181
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]