Jump to content
  • Advertisement
Sign in to follow this  
matom

Display 24-bit bitmap has a problem

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

When I copy a bitmap from double_buffer to primary_buffer has a problem like this: http://202.206.208.253/bbs/UploadFile/2006-4/200642311123025501.bmp one line display the bitmap but the next display black... If you cann't see the bitmap please tell me. I will send a E-MAIL to you. Please Help! DisplayMode 640*480*32 and bitmap 24-bit some code DWORD *dest_ptr = primary_buffer; DWORD *src_ptr = double_buffer; // memory is non-linear, copy line by line for (int y=0; y < SCREEN_HEIGHT; y++) { // copy line memcpy((void *)dest_ptr, (void *)src_ptr, SCREEN_WIDTH*4); // advance pointers to next line dest_ptr+=ddsd.lPitch; src_ptr +=SCREEN_WIDTH*4; } // end for

Share this post


Link to post
Share on other sites
Advertisement
The pitch is given in BYTES per line, but you add it onto a DWORD (32bit) pointer. If you increase a pointer it will be increased in the pointees size. In your code if you add the pitch you really add the pitch multiplied by 4 (4 bytes in a DWORD). You also multiply SCREEN_WIDTH by four which will have the same effect.

Changing the DWORD* of dest_ptr and src_ptr to BYTE* should do the trick. You may have to cast if your primary_buffer and double_buffer are DWORD (pointers or arrays):

BYTE* src_ptr = (BYTE*)double_buffer;
BYTE* dest_ptr = (BYTE*)primary_buffer;

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!