Jump to content
  • Advertisement
Sign in to follow this  
JoeZ

GetDibits and GetObject

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

Hi, I have a question regarding GetObject(hbitmap,sizeof(BITMAPINFO),&bminfo); The function failed to init the biBitCount field. Does the function work with getting bitmapinfo structure? Maybe I should use GetObject(bitmap,sizeof(DIBSECTION),&ds);? I know that the bitmap bit count(32bit) and I init that field myself then I try to use GetDibits to get the pixel values from the bitmap and again it failed. Here is my code. Do you see anything wrong? //bitmap already loaded GetObject(hBitmap,sizeof(BITMAP, &bitmap); GetObject(hBitmap,sizeof(BITMAPINFO),&bminfo); HDC hdcMem = CreateCompatibleDC(NULL); SelectObject (hdcMem,hBitmap); COLORREF *pix = new [bitmap.bmWidth * bitmap.bmHeight] GetDibits( hdcMem, hbitmap, 0, bitmap.bmHeight, pix, &bminfo, DIB_RGB_COLORS); int r = GetRValue(pix[0]); int g = GetG.. int b .. r, g, b are all equal to 205 but the color at (0,0) is pure blue. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
well if you just create a dc then it will have a black and white bitmap in it. :), Unless you create a dc from another dc it will be initialized that way.

Are you checking that GetObject's return code?? it returns 0 on failure.

Cheers
Chris

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!