Jump to content
  • Advertisement


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


bitmaps and palettes...AHHH!!

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, somebody HAS to explain this to me! How do I load and display a bitmap on the screen? I've looked at the DirectX SDK and I have Windows Game Programming for Dummies. In each case I have read the sections on palettes and bitmaps multiple times and still I can't get it! Let's say I've already created the DirectDraw object, the primary surface, and the backbuffer. What next? What is all this about the palette? Also, when dealing with bitmaps, why are there so many functions that appear to be the same and what is the difference between them all? Ex: DDLoadBitmap(); DDReLoadBitmap(); LoadImage(); Do the differences have anything to do with loading bitmaps to the off-screen surface vs. the primary or secondary surface? I guess one of the biggest ways you could help me is to explain, in plain English, the steps to loading/displaying a bitmap. (e.g. Create DirectDraw object, create surfaces, create and attach palette, etc.) Or whatever the real order is. Then, once I know this, I can bug you guys even more on how to physically code it. Please help in any way you can. I will probably continue to have many questions so this may turn out to be a fairly long thread. Thanks in advance. --- Joker2000 Stevie Ray Vaughan - The Legend Edited by - Joker2000 on 7/14/00 2:22:37 PM

Share this post

Link to post
Share on other sites
LoadImage() is from the Win32 API...

DDLoadBitmap() loads a bitmap and returns a pointer to a surface where the bitmap is located.. you gotta release the surface, since it''s being allocated withing the function...

DDReLoadBitmap(), even though ive never used this function (i havent even used DDLoadBitmap()), by the name i would think that you need to pass a surface that has been allocated, and the function will simply load a bitmap into that surface, without creating a new one in the function... just my thoughts(not a fact!!)

palettes... hmm.. those are used when you work in an 8-bit color mode (and when you;re loading an 8-bit bitmap)... a palette is basically a collection of RGB triplets which predefine the colors that are going to be used on the screen (surface)... when you write to a surface that''s working with 8-bit colors, then the only thing you need to place in surface''s memory is a single byte, which represents an index to the palette that has been attached to the surface.. with that index, DX is able to get the color (that you defined [the RGB triple]) from the palette (the array of colors), and place it on the screen. That''s the way Mode 13h works, and i think it''s easier to learn how to use a palette in DOS, than it is in Windows... just my 2 bucks... i mean cents..


Share this post

Link to post
Share on other sites
Here you go:

You create the surface. You ignore palettes for now and make your program run in a 16 or 24 bit color mode (You should know what your computer can handle). At some point you do the following:

(SurfaceName) = DDLoadBitmap((Main DirectDraw Object),
(Bitmap File),
(Bitmap Size X),
(Bitmap Size Y));

if( !(SurfaceName) )
error("(SurfaceName) = DDLoadBitmap");
return FALSE;

Some of this code (Like the error function and return call) depend on your program but you should get the idea.

Retired Pokemon Master of Prgramming Problems

I already had them all.

Share this post

Link to post
Share on other sites
Suggestion: Stick to 16, 24 or 32 bit and avoid palettes, at least initially. Most paint programs will save in these modes. While paletted bitmaps save space, they add complexity to your programming effort and limit the number of colors you can work with.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!