wgpfd bitmap loading

Started by
16 comments, last by lpsoftware 24 years, 1 month ago
If I remember correctly, the engine as-is is setup to use 8-bit mode. You need to make sure that you are using a USHORT pointer to surface memory instead of a UCHAR and that you divide the lpitch by 2 (or right shift 1). That''s the first thing that comes to mind.
Advertisement
That''s what I was thinking, (you don''t have to post it four times hehehe)
what Aldacron? i didn''t catch that could you repeat it please?
-werdup-
Jeez, I didn''t know I had posted at all. I kept getting an error message. Something about integer overflow.
I've been investigating my problem further, and in the code where Lamothe loads 16 bit pictures he still uses UCHAR, but he doubles the width and size of the picture when he copies it to the primary buffer:

16 bit:
// copy each bitmap line into primary buffer
// taking into consideration non-linear video
// cards and the memory pitch lPitch
for (int y=0; y < SCREEN_HEIGHT; y++)
{
// copy the line
memcpy(&primary_buffer[y*ddsd.lPitch], // dest address
&bitmap16bit.buffer[y*SCREEN_WIDTH*2],
SCREEN_WIDTH*2);
} // end for y

8 bit
for (int y=0; y < SCREEN_HEIGHT; y++)
{
// copy the line
memcpy(&primary_buffer[y*ddsd.lPitch], // dest address
&bitmap8bit.buffer[y*SCREEN_WIDTH], // src
SCREEN_WIDTH); // bytes
} // end for y


But I can't figure out how to apply this to the engine he built. This is the code in the engine:

// extract bitmap data
source_ptr = bitmap->buffer + cy*bitmap->bitmapinfoheader.biWidth+cx;

// get the addr to destination surface memory

// set size of the structure
ddsd.dwSize = sizeof(ddsd);

// lock the display surface
(bob->images[frame])->Lock(NULL,
&ddsd,
DDLOCK_WAIT / DDLOCK_SURFACEMEMORYPTR,
NULL);

// assign a pointer to the memory surface for manipulation
dest_ptr = (UCHAR *)ddsd.lpSurface;

// iterate thru each scanline and copy bitmap
for (int index_y=0; index_yheight; index_y++)
{
// copy next line of data to destination
memcpy(dest_ptr, source_ptr,bob->width);

// advance pointers
dest_ptr += (bob->width+bob->width_fill);
source_ptr += bitmap->bitmapinfoheader.biWidth;
} // end for index_y

// unlock the surface
(bob->images[frame])->Unlock(ddsd.lpSurface);

Edited by - Chrono999 on 3/15/00 2:30:40 PM
If your using 16 bit, you should use a USHORT pointer.

"When people tell you they want to hear the truth, you know that their lying."
Yeah, I''ll keep on trying that, but it screws everything up. Oh well
Thanks a lot everyone, I finally got it. (sorry for being an idiot)

This topic is closed to new replies.

Advertisement