Loading bitmaps from resource scripts

Started by
4 comments, last by Bigshot 24 years, 1 month ago
How do you do this? Right now all my bitmap files are just files on my hard drive that anyone could alter if they played my game... so I''m going to put my bitmaps in a resource script in Visual C++, but now I need to write a new bitmap loader and I''m not sure how to do this with resource files. I know it''s something like LoadBitmap(NULL, resource) but I need to know exactly how to load the file and read it as a bitmap. Also, what I''m going to do is load the bitmaps and copy them to DirectDraw surfaces... then I wouldn''t need the resources in memory anymore after that, so do I have to free resources from memory just like normal files? Thanks, Al
Alexbigshot@austin.rr.comFoolish man give wife grand piano. Wise man give wife upright organ.
Advertisement
This may or may not apply to you, depending on if you are rolling your own engine or not, but libCON is a free game engine that comes with a binary to compile all your resources into a file and the library already provides all the decompression stuff that you need to extract. You should be able to find it on the net.
Mike BarelaMikeB@yaya.com
One can still edit the graphics in your game even if they are included in a resource file.
William Reiach - Human Extrodinaire

Marlene and Me


Loading a bitmap from resources is very simple.

HBITMAP h_image;
BITMAP image;
HDC hdc_image, hdc_dds;
LPDDRAWSURFACE lpdds;

// Loading a bitmap

h_image = LoadBitmap(hInstance,MAKEINTRESOURCE(ID_OF_YOUR_BITMAP));
GetObject(h_image, sizeof(BITMAP), ℑ);

// Now you have bitmap loaded in and ready to use

// You may select it to device context and blit to DirectDraw surface

lpdds->GetDC(&hdc_dds);
hdc_image = CreateCompatibleDC(hdc_dds);
SelectObject(hdc_image, h_image);
BitBlt(hdc_dds,x,y,width,height,hdc_image,0,0,SRCCOPY);
lpdds->ReleaseDC(hdc_dds);

// Release resouces from memory
DeleteDC(hdc_image);
DeleteObject(h_image);

quote:Original post by Gromit

One can still edit the graphics in your game even if they are included in a resource file.


Not if they are encrypted.


Photon

I'm programming a 3d engine but I prefer making my own file format for the game resources, so I know exactly how to load them.

Visite our homepage: www.rarebyte.de.st

GA @ Rarebyte

Edited by - ga on 3/22/00 10:57:35 AM
Visit our homepage: www.rarebyte.de.stGA

This topic is closed to new replies.

Advertisement