Advertisement

16-bit BMP files?

Started by March 19, 2000 04:18 PM
4 comments, last by BeanDog 24 years, 11 months ago
My 24-bit bmp files I am loading onto a 16-bit surface seem like they could be much smaller if they were in 16-bit format. Is there a way to save to 16-bit format? Paint and PaintShopPro go from 8-bit to 24-bit all in one shot. ~BenDilts( void );
well, 16-bit mode isn''t very usually (i.e on most cards, different amount of bits for each color [5.6.5]), so most programs don''t save in 16-bit.
Advertisement
Well, I had the same thought so I wrote this tiny little program to do the job sometime ago. It converts a 24-bits bitmap to a 16-bits bitmap, no rasteration or what so ever.
(I can''t guarantee it works in all situations! I never used it much or did any extensive testing/debugging)

http://www.xpress.se/~jagi1216/bmp16.exe



"I think, therefore I am...I think"
Oh yeah, the input image''s width must be a multiply by two. Don''t ask why!



"I think, therefore I am...I think"
I wrote a program that saved 16 bit bitmaps in a large file, for use in an RPG. All you need to do is open your 24 bit bitmap, and for each pixel, bitshift the red right by 3, green by 2, blue by 3. That'll give you 5,6,5, and reduce your file size by a third. Put them into a word:

WORD colour ;

//open file, get data, start loops etc in this space
//for every pixel (RGB already in 5,6,5):
red <<= 11 ;
green <<= 5 ;
colour = red / green / blue ;

Then write "colour" to a file, replacing the 24 bit data for each pixel. Then, when you load that file back into your program, you can shift the RGB values back to 24 bit colour if you need to, with only a minor loss in quality. From there, you can bitshift the data to comply with whatever bitmasks DirectX wants you to use (there are tutorials on Gamedev for that). Good luck!

-----------

C++ is the language of the not-so-ancients.
Learn to speak it well.


BeamMeUp

Edited by - BeamMeUp on 3/20/00 12:38:26 AM
-----------C++ is the language of the not-so-ancients.Learn to speak it well.BeamMeUp
Sorry, the forward slashes in my code above can''t be changed... They are supposed to be Shift + "\" (bitwise OR operator) but it doesn''t like me doing so. Why is that...?
-----------C++ is the language of the not-so-ancients.Learn to speak it well.BeamMeUp

This topic is closed to new replies.

Advertisement