Jump to content
  • Advertisement


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


Why are the bits STILL null?

This topic is 5585 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''m trying to access the bits of bitmap directly because GetBitmapBits is too slow and only copies the bits, which requires you to use SetBitmapBits again when you have finished with them. Here''s the code I''m using, but no matter what I do, the bits are always 0x00000000. All other BITMAP values are correct however
this->FrontBuffer = GetDC(this->hWnd); //main window (already created)

this->BackBuffer = CreateCompatibleDC(this->FrontBuffer);
SetBkMode(this->BackBuffer, TRANSPARENT);
this->backBmp = CreateCompatibleBitmap(this->FrontBuffer, this->width, this->height); //bitmap is created.  Should have width*3*height BYTES

SelectObject(this->BackBuffer, this->backBmp);
//access the bits of the BackBuffer and modify

GetObject(this->backBmp, sizeof(BITMAP), &bmp);
bits=(BYTE*)bmp.bmBits; <----- Here they are always NULL.

Share this post

Link to post
Share on other sites
Checked the result of GetObject, or the value of scanw?

MSDN sayeth:

Object type Data written to buffer

HBITMAP returned
from a call to
CreateDIBSection DIBSECTION, if cbBuffer is set to sizeof
(DIBSECTION), or BITMAP, if cbBuffer is
set to sizeof(BITMAP)

"If hgdiobj is a handle to a bitmap created by calling CreateDIBSection, and the specified buffer is large enough, the GetObject function returns a DIBSECTION structure. In addition, the bmBits member of the BITMAP structure contained within the DIBSECTION will contain a pointer to the bitmap's bit values.

If hgdiobj is a handle to a bitmap created by any other means, GetObject returns only the width, height, and color format information of the bitmap. You can obtain the bitmap's bit values by calling the GetDIBits or GetBitmapBits function."

Looking at the first table, you seem to be using the 2nd method, and therefore it's implying that it doesn't make bmBits available to you except through GetDIBits or GetBitmapBits.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

[edited by - Kylotan on July 2, 2003 9:53:19 AM]

[edited by - Kylotan on July 2, 2003 9:53:38 AM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!