Jump to content
  • Advertisement
Sign in to follow this  

Really frustrated...

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

Can someone tell me where the heck this code is going wrong. I have some memory with 8 bit values that I want do display in a picture control. IDC_DISPLAY is a picture box set to type Rectangle (although changing it to other types doesn't help). Globally I declare these variables and initialize them as follows:
CWnd *Display;
CDC *dispDC;

Display = new CWnd();
Display = GetDlgItem(IDC_DISPLAY);
dispDC = new CDC();
dispDC = Display->GetWindowDC();

Then when a timer goes off I want to take the values in this temp buffer that have been filled in and display them. Here is what I do:
CDC memDC;
CBitmap bm;
DWORD dwVal;

//dwVal = bm.CreateBitmap(width, height, 1, 8, temp);
//dwVal = bm.SetBitmapBits(width*height, temp);
dispDC->BitBlt(0,0,width, height, &memDC, 0,0,SRCCOPY);

Using LoadBitmapA() works fine with predefined bitmap, but SetBitmapBits() returns an error saying it has an invalid handle and CreateBitmap() returns success but the display is blank. Can anyone tell me 1) Why this doesn't work 2) What the best way to do what I'm trying to do is The 8 bit values are grayscale so I'm assuming I have to set up a color palette but I can't even get the stupid basic stuff to work. Thanks, Andrew

Share this post

Link to post
Share on other sites
Ok here's some more info. I originally thought the temp array could just have the same number of bytes as pixels in my image, but is this correct? Do I have to have 3x the number of pixels for the RGB information?

When I call
dwVal = bm.CreateBitmap(width, height, 1, 8, temp);

bm.GetBitmap() everything looks ok except the bmBits pointer which is NULL

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.

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!