Archived

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

PPCThug

how does every one else load .bmp's into directdrawsurfaces?

Recommended Posts

I need a few comparisons to what I have ben doing.
the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.

Share this post


Link to post
Share on other sites
I use PCX files (same BMP characteristics, takes less space in my hard drive)

I wrote my own CPcxImage Class, it has a LPDIRECTDRAWSURFACE7 member, which I Create and Lock to put the data in after decoding the PCX File, after that I just use Blt or BltFast on the destination surface using the LPDIRECTDRAWSURFACE7 member of the class.

Share this post


Link to post
Share on other sites
I meant how exactly do you copy the info over do you use a library function or make your own? if you make your own can I please see a generic example?



the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.

Share this post


Link to post
Share on other sites
Its been a long time since I used direct draw, but if I remember correctl there are basically 2 ways to do it. First you can load the image and lock the surface and manually copy the bits over. (see LoadImage and GetDIBits). Thats fine if your surface matches the format and resolution of your surface -- otherwise you have to do some converting manually. The easier way is just to have GDI do the conversion (and any necessary resizing) for you. Load the image, get a DC for the surface, and have GDI blt the image onto the surface. (see LoadImage, StretchBlt).

see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_87eb.asp

Share this post


Link to post
Share on other sites
It''s been a while since I used DirectDraw, but I recall that the SDk comes with some DirectDraw helper stuff (dd_util, I think). It should be in the Common folder in the SDK. It has a BMP loader you can look at.


Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
in the book I''m reading the only way to write to a ddsurface is either blt from a nother ddsurface or to

USHORT *pddsurface = (USHORT *)ddsd.lpSurface;

// process each line and copy it into the primary buffer
for (int index_y = 0; index_y < SCREENHEIGHT; index_y++)
{
for (int index_x = 0; index_x < SCREENWIDTH; index_x++)
{
// get BGR values, note the scaling down of the channels, so that they
// fit into the 5.6.5 format
UCHAR blue = (bitmap.buffer[index_y*SCREENWIDTH*3 + index_x*3 + 0]) >> 3,
green = (bitmap.buffer[index_y*SCREENWIDTH*3 + index_x*3 + 1]) >> 3,
red = (bitmap.buffer[index_y*SCREENWIDTH*3 + index_x*3 + 2]) >> 3;

// this builds a 16 bit color value in 5.6.5 format (green dominant mode)
USHORT pixel = _RGB16BIT565(red,green,blue);

// write the pixel
pddsurface[index_x + (index_y*ddsd.lPitch >> 1)] = pixel;

} // end for index_x

} // end for index_y



the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.

Share this post


Link to post
Share on other sites
on gamedev they have an article about using the DIB functions to copy raw bitmap data onto a surface. I made my own format using ZLIB. this is the best option for me, its very simple and works great! Copying data directly onto the surface is ok, but you have to deal with all the posible color combinations

Share this post


Link to post
Share on other sites
I copy it by locking and manually loading & copying the data myself. You do have to worry about different formats and all that, but on the other hand, you can modify the data at load time which is useful.

Share this post


Link to post
Share on other sites