Archived

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

Dismantler

Copy Screen to primary surface

Recommended Posts

I have a function called Copy_Screen, but it only copies half of my bitmap that''s loaded into memory. It''s for 16 bit. Here it is: int Copy_Screen(UCHAR *source_bitmap,UCHAR *dest_buffer, int lpitch, int transparent) { UCHAR *dest_addr, // starting address of bitmap in destination *source_addr; // starting adddress of bitmap data in source UCHAR pixel; // used to hold pixel value int index, pixel_x, lpitch_2 = lpitch >> 1; // compute starting destination address dest_addr = dest_buffer; // compute the starting source address source_addr = source_bitmap; // is this bitmap transparent if (transparent) { // copy each line of bitmap into destination with transparency for (index=0; index< SCREEN_HEIGHT; index++) { // copy the memory for (pixel_x=0; pixel_x

Share this post


Link to post
Share on other sites
Now it''s asking for a cast!! How would I do this?

error C2664: ''Copy_Screen'' : cannot convert parameter 1 from ''unsigned short'' to ''unsigned short *''
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

Is it something like (USHORT *) then the call to Copy_Screen?

Share this post


Link to post
Share on other sites
Nevermind, I forgot to lock the primary surface... =^|

Heh, I''m talking to my self...

But now it copies a 1/4 of the bitmap, which is worse than the first time... Help?

Share this post


Link to post
Share on other sites
Well, your first task should have been to tell us whether it''s calling it with transparent = true or transparent = false first. And to try it with both variations. That cuts your debugging time by half, assuming that only 1 of them is bugged. As it is, we have to look through both sections when, most likely, only one of them has a problem.

My first guess is that you have no reason to be dividing pitch by two. If you are using USHORT* for dest_addr, then pitch is measured in pixels and therefore shouldn''t be halved.

Share this post


Link to post
Share on other sites
Thanks for the help, but I figured it out on my own. =^)

Kylotan was right, only one of them are bugged, the non-transparent one. So i used the transparent one which gave the same result. Once again, thanks for the help guys.

Share this post


Link to post
Share on other sites