Archived

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

roger_hq

Loading 24-bit bitmaps from resource files in Visual Studio 6.0

Recommended Posts

Hello, Im pretty new to DirectX and game programming, and I have a pretty basic question. I am writing a 2D scroller game which loads 16 or 24 bit color bitmaps into DirectDraw 7 surfaces. Currently, I am loading them from a file in game's directory structure. The problem with this is that a user can go into those files and modify them however they want, so the bitmaps could be changed to look differently than what I originally created. I wanted to be able to keep my artwork unmodified when I release the game. My idea was to create the images used by the game as resources in Visual studio, so the end user does not have access to them. The problem is, that when I load images from a resource and not a file, the image is only loaded with 4 bit color (which I believe is the default palette for a bitmap resource). I obviously want to keep the 24 bit palette that the image is actually created in. Therefore, the question is, how do I make bitmaps loaded from a resource keep the color depth that the image is saved as? Thanks in advance, roger_hq [edited by - roger_hq on August 14, 2002 3:15:07 PM]

Share this post


Link to post
Share on other sites
Using LoadImage() it should load fine, as long as you then load the resulting HBITMAP into your surface correctly. Ugh, I haven''t had the need to mess with this stuff for a while, I''ll paste you some code from an older (and not currently in use) bit from my graphics classes that I believe worked correctly, if not then play with the LoadImage flags, I don''t remember what CREATEDIBSECTION did:


  
// try to load the bitmap as a resource

hBMP = (HBITMAP) LoadImage( GetModuleHandle(NULL), strBMP,
IMAGE_BITMAP, dwDesiredWidth, dwDesiredHeight,
LR_CREATEDIBSECTION );


You can try that, I think I copy pasted that out of Microsoft''s DDUtil or something in fact.

Drawing the bmp to the surface then is just a matter of getting a DC to the surface, creating another DC (that is compatible), selecting the bmp into the dc, and blting it to the surface DC, like you would with the normal Win GDI.

If the above isn''t working for you, then paste or tell us exactly what you are doing to load the bitmap.

PS. I don''t think you should store all the game graphics as resources.

Share this post


Link to post
Share on other sites


Thanks for your reply. I will try that when I get the chance. I saw your "PS" at the bottom of your email and was wondering why you would not use resources for your images... just so your executable is smaller, or some other reason that isn''t as obvious?


roger_hq

Share this post


Link to post
Share on other sites
Using resources effectively is hard coding your game. While in practice, this can be perfectly fine, in today''s era of game design making a game engine versatile and truly separating game data and game code is a big thing. In short, you want a game that it is possible to make mods for, that''s good design. Even ignoring that goal, you do not want an icky large exe. Just having to constantly recompile your game to change some graphics is time consuming and can quickly "get to you". It would also be difficult to manage the resources elegantly, and I think there''s other problems as well but I am not an expert on resources I''m afraid. I''m guessing that you are making this game primarily with the intent to learn and move on to bigger games. Therefore the strongest argument against your idea is that you will not get any experience managing game graphics in the more traditional and accepted ways and when you get to bigger projects you will end up having to learn to do it anyway (which will suck because on a bigger project there is quite a lot of stuff to code so learning the basics wastes precious time and results in a lower quality product). If you are really against people modifying your graphics (and believe people would want to in the first place) go for it, else why waste your time?

Share this post


Link to post
Share on other sites