#### Archived

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

# Run-time resources

This topic is 6937 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

##### Share on other sites
What I have done to get the bitmaps onto the surface is quite simple- If you stored the bitmaps in your ''wadfile'' (hehe) just as they are in .bmp format (byte for byte).

Since you know the file is a BMP file, you can get the width and height of it directly from your wadfile. You will have to find the BMP file specification to know at what offset the width and height are stored.
Once you have the width and height, create an offscreen directdraw surface with those dimensions.
Now comes the hard part. You have to read in the data part of the BMP byte for byte and write it directly on the offscreen surface. Writing is tricky however, and varies with the bit depth of the BMP file in the wadfile. If its a 24-bit BMP file, you know there are 3 bytes for each pixel, 16-bit has 2 bytes/pixel and 8-bit has 1 byte (but can also have a palette).

If this is the type of information you require, ICQ me @ 1888925.
[MG]Kaewan

The Mage Guild

##### Share on other sites
You can do like this:

void LoadBMP24 (int width, int height, void *data){    /* 'data' points to the actual bits/byte of the image */     BITMAPINFO bi;    memset (&bi, 0, sizeof(bi));    bi.bmiHeader.biSize = sizeof (bi.bmiHeader);    bi.bmiHeader.biWidth = width;    bi.bmiHeader.biHeight = height;    bi.bmiHeader.biPlanes = 1;    bi.bmiHeader.biBitCount = 24;    HDC dc;    ddsurface1->GetDC (&dc);    ::StretchDIBits (dc,        0, 0, width, height,        0, 0, width, height,        data, &bi, DIB_RGB_COLORS, SRCCOPY);    ddsurface1->ReleaseDC (dc);}

Correct me if i'm wrong. This works with only 24bit BMP. Need to modify for loading in other bit depth.

Edited by - DerekSaw on 4/26/00 10:04:48 AM

##### Share on other sites
Hi, thanks Derek. I looked at your post, and I started thinking. Then I looked in the Windows API files in a way that I was apparently unable to do a few hours ago.

And I found it-- CreateDIBitmap. You send it a BITMAPINFOHEADER, a BITMAPINFO, and a pointer to the bitmap''s bits, and you''re in business.

Thanks for your help, though-- while it wasn''t the answer I was looking for, it somehow put me into the right frame of mind. Three Cheers!

-- Goodlife

-----------------------------
Think of your mind as a door on a house. Leave the door always closed, and it's not a house, it's a prison. Leave the door always open, and it's not a house, it's a wilderness-- all the vermin creep in.

##### Share on other sites
I think you are missing one variable for that function. Don''t you need an index or some offset to the start of the data for that one bitmap?

Something like:
LoadBitmap(int bmID, char *data, int w, int h);

Of course, w and h MAY be in the data itself, I can''t remember.

##### Share on other sites
Goodlife: Three Cheers!

Buster: Hmm... maybe I add one more paramter as accepting an IDirectDrawSurface*. Here''s a sample I call the function:

// ... some code here ...FILE *fp_in = fopen ("TEST.BMP", "rb");long size = filelength (fileno (fp_in));unsigned char *buf = new unsigned char[size + 1];fread (buf, 1, size, fp_in);BITMAPINFOHEADER *bih = buf;LoadBMP24 (lpddsBackground, bih->biWidth, bih->biHeight, buf + bih->dwOffset);// ... do some cleanup ...

The code might be wrong... but it is something like this (I just simply type this without looking my code).

• 15
• 13
• 35
• 39
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!