Jump to content
  • Advertisement

Archived

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

8bpp BMP on 16bpp surface

This topic is 6621 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

I loaded a 8bpp BMP on a 16bpp surface. When I use GetPixel (GDI), I don''t obtain the right RGB value, why? Example: I know that a pixel in the BMP has RGB values : (0,0,1). When I use GetPixel, the COLORREF (i.e. a DWORD) returned is 0. Thanks in advance for your help! Ivan

Share this post


Link to post
Share on other sites
Advertisement
well, what i see wrong here is that your loading an 8-bit image onto a 16-bit surface. Unless, you convert the 8-bit pixel data for each pixel to 16-bit, you''re gonna get errors. To convert each value, you can get the RGB values from each 8-bit pixel (pixel.peRed, pixel.peGreen, pixel.peBlue), and then store each one in a COLORREF to generate the 16-bit color.
THen i suggest you make your own GetPixel type function, so that way you can know exactly what''s goin'' on. Exp:
COLORREF GetPixel(int x, int y, USHORT *buffer, int buffer_pitch)
{
COLORREF temp;
temp.Red /* Or whatever it''s supposed to be */ = buffer[x + y*buffer_pitch].peRed;
temp.Green = buffer[x + y*buffer_pitch].peGreen;
temp.Blue = buffer[x + y*buffer_pitch].peBlue;
return(temp);
}

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!