Sign in to follow this  
matom

Display 24-bit bitmap has a problem

Recommended Posts

matom    122
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
Endurion    5411
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this