🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

16bit background picture problem....

Started by
5 comments, last by ViPeR007 24 years, 8 months ago
Dang, should have registered first so that I could edit the message above :-) O well, I meant 2d engine, not 3d. Also when I run the program all it does is show a black screen for a second and then boot out, no errors or anything. I was thinking that it was a problem with surfaces but I haven't found anything wrong yet.

Thanx again,
ViPeR

Advertisement
What did you use to make the bitmap? If photoshop thats your problem. Photoshop stores bmp data a little differnt and gbdumb's bitmap loader cant read it. If this is the case just load the bmp in ms paint and resave it then try.
I used Paintshop Pro 5.0. Do you know how to make it convert a picture to 16bit? Because all it has is 8 and 24bit color modes.

Thanx,
ViPeR

paintshop pro supports 16-bit bitmaps

------------------
Skullpture Entertainment
#40842461

Graphix Coding @Skullpture Entertainmenthttp://www.skullpture.de
I think, your problem is that the BMP format does not support 16 bit color depht. So if you wanna use 16 bpp pictures, you have to convert a 24 bpp picture into 16 bpp picture.

In 24 bpp picture each pixel is represented by 3 bytes, in the following RGB format:

MSB: RRRRRRRR GGGGGGGG BBBBBB :LSB

As yo can see, every component is represented by one byte.


in 16 bpp picture each pixel is represented by 2 bytes in the following RGB format:

MSB: RRRRR GGGGGG BBBBB :LSB

Here, the RED and BLUE components are represented by 5 bits, and the GREEN component is represented by 6 bits.

To convert from 24 bit to 16 bit

24: RRRRRRRR GGGGGGGG BBBBBBBB
| || || | || || | | || ||
| || || | || || | | || ||
16: RRRRR GGGGGG BBBBB

You have to mask out the upper 5 bits from the RED and BLUE components, and the upper 6 bits from the GREEN component, then you have to shift them into the correct position.
Here is the macro I am using:

#define _RGB16BIT(b,g,r) ((b>>3)+((g&252)<<3)+((r&248)<<8))

If it does not work, you should try the 15 bpp mode. It is the same as the 16 bpp pixel format, but all the components are represented by 5 bits, and the MSB bit is always 0.

MSB: 0RRRRR GGGGG BBBBB :LSB

Ok all Im trying to do is load an image into the back buffer and then draw it onto the screen so that its a bacground picture. Im using the DirectX 3d engine from the dummies book by Andre LaMothe. So in Game_Init I have:
Load_Bitmap_File(&bitmap16bit, "BACK.BMP");
Create_Bitmap(&back, 0,0, 640, 480);
Load_Image_Bitmap(&reactor,&bitmap16bit,0,0,BITMAP_EXTRACT_MODE_ABS);
Unload_Bitmap_File(&bitmap16bit);

And then in Game_Main I have:
// clear the drawing surface
DD_Fill_Surface(lpddsback, 0);

// lock the back buffer
DD_Lock_Back_Surface();

// draw the background image
Draw_Bitmap(&back, back_buffer, back_lpitch, 0);

// unlock the back buffer
DD_Unlock_Back_Surface();

Can anyone tell me what I am doing wrong?

Thanx,
ViPeR

OOOPS!

I have just seen, that the figure, which is intended to explain the converting method from 24 bit to 16 bit, is a little weird.

I am sorry for that, but I hope you get the point.

This topic is closed to new replies.

Advertisement