Thanx again,
ViPeR
16bit background picture problem....
Thanx,
ViPeR
------------------
Skullpture Entertainment
#40842461
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
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
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.