#### Archived

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

# blue tint in 16-bit?

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

## Recommended Posts

when i display a 16-bit bitmap in 640x480x16 all the colors have a blue tinge(?) to them. anybody have this happen? (im using lamothes bitmap loading functions to do this)

##### Share on other sites
I havent had this happen to me but I know other people who have had this problem. I think its because there is something wrong in one of his macros RGB macros.

##### Share on other sites
Yup, Lamothe got lots of bugs in his code.
Here's the right macros: (The 565 is good, not sure about the 555)

#define RGB16_555(r,g,b) ((b & 31) + ((g & 31) << 5) + ((r & 31) << 10))
#define RGB16_565(r,g,b) ((b & 31) + ((g & 63) << 5) + ((r & 31) << 11))

(I changed the names of the macros a bit, but you get the point)

Then in Load_Bitmap_File() you should find the place where Lamothe converts a 24bit bitmap to 16bit.
Something like this:

USHORT color;
UCHAR red = temp_buffer[index*3+0]>>3,
green = temp_buffer[index*3+1]>>3,
blue = temp_buffer[index*3+1]>>3;

color = RGB16_565(red,green,blue);

The green shift is wrong, it should be:
UCHAR green = temp_buffer[index*3+1]>>2;

Goodluck

The road to success is always under construction

Edited by - Tornado on September 3, 2000 6:45:57 AM

##### Share on other sites
thanks tornado you were right... well almost. i just needed to convert the macro from _RGB16BIT((r%32)+((g%32)>>5)+((b%32)>>10))
to >>6 and >>11 but as for the Load_Bitmap_File function that works fine... at least so for it does. when i decide to check the computer for its color format i''ll have to change it.

##### Share on other sites
_RGB16BIT((r%32)+((g%32)>>5)+((b%32)>>10)) is from Lamoth code? You sure? I havn''t seen it
I should have mentioned that the part where you change Load_Bitmap_File() stands for the 565 part. I havn''t touched 555.
Have fun coding

##### Share on other sites
I have seen some strange things here.

((b & 31) + ((g & 31) << 5) + ((r & 31) << 10))

while xtrmntr''s code looked like this:
((r%32)+((g%32)>>5)+((b%32)>>10)).

So my question is: is x&31 the same as x%32?

##### Share on other sites
If you''re going to be using 0-255 for you min-max color ranges, it would probably be best to use macros somewhere along the lines of these:

//(555) used to convert from rgb values (0 - 255) to 15 bit color
#define _RGB15BIT( r, g, b ) ((b>>3)+((g>>3)<<5)+((r>>3)<<10))

//(565) used to convert from rgb values (0 - 255) to 16 bit color
#define _RGB16BIT( r, g, b ) ((b>>3)+((g>>2)<<5)+((r>>3)<<11))

With the ones you are using (which mods by 32): 31, 63, 95, 127, 159, 191, 223, and 255 all come out as being max intensity in your colors. Of course this really only matters if you are using your macros to convert from other bitmap resolutions to 16bit.

##### Share on other sites
quote:
So my question is: is x&31 the same as x%32?

Actually, I think it is.

89 & 31 = 25 = 89 %32

The road to success is always under construction

##### Share on other sites
Tornado: the macro im using i got from LaMothes "For dummies book"

##### Share on other sites
Anonymous: i tried both of your macros and the first one makes my colors look wacked while the second one makes all the colors alot darker then the way i drew them. can you explain a little more about why i would choose yours over mine?

1. 1
2. 2
Rutin
21
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633307
• Total Posts
3011290
• ### Who's Online (See full list)

There are no registered users currently online

×