Question about 16-bit BMP's
Ive just made myself a little function thats to load 16-bit BMP images onto a surface, problem is that i cant seem to get my hands on a 16bit BMP file.
I tried various programs but all the images was logged(in my program) as having either 1 byte per pixel(8bit) or 3 bytes per pixel(24-bit).
I would sort of expect a 16-bit image to have 2 bytes per pixel.
I even tried the andre16.bmp that comes with the Windows game programming for dummies book(thats all i could find at the library but when i load that in it also has 3 bytes per pixel!(which is weird because in the book the author explicitly writes 2 where the bytes per pixel are needed).
Are there any shareware/freeware programs that can give the correct values for bitmaps and also can save in various formats?
I dont think im loading the imagedata wrong, the FILHEADER and INFOHEADER structures are being correctly filled, and i seem to be loading the right amound of data(ie, height*width*the reported bytes per pixel).
as far as i know .bmp is always 8bit or 24 bit! if you want 16bit, write a converter by yourself!
"be fair! ... always"Zeusel
Thats pretty funny because in the game prog. for dummies there is a headline that reads "Loading 16-bit hi-color bitmaps" inside the chapter dealing with loading BMP files.
This is pretty annoying because 8-bit is not enough for what i need, but 24-bit is way to many color(and takes up too much memory). Thats why i want 16-bit which is around 65k colors.
I could perform the conversion myself, but that would be pretty stupid, saving things in a different format than the one im going to use, why add the overhead. Are there any other noncompressed file formats that store 16-bit?
This is pretty annoying because 8-bit is not enough for what i need, but 24-bit is way to many color(and takes up too much memory). Thats why i want 16-bit which is around 65k colors.
I could perform the conversion myself, but that would be pretty stupid, saving things in a different format than the one im going to use, why add the overhead. Are there any other noncompressed file formats that store 16-bit?
hmmm, theres: monochrome, 16 color, 256 color, 24bit bitmaps
/me thinks you want 16 color, not 16bit. MSPaint creates these for you just fine.
/me thinks you want 16 color, not 16bit. MSPaint creates these for you just fine.
to my knowledge there are no software packages that save in 16 bit. In the TOTWGPG book he tells you this and also tells you how to do a conversion. I myself went straight to 24bit on my newest project.
- Free Your Mind -
- Free Your Mind -
- Free Your Mind -
16bit colour is included in the BMP format. Paint can load 1bit, 4bit, 8bit, 16bit and 24bit bitmaps but can only "save as" in 4, 8 and 24. You''ll just have to write your own converter or find a piece of software that has bothered to included it. If your using delphi here''s the code:
procedure ConvertTo16Bit(FileName:String);
var BitMap:TBitMap;
begin
BitMap:=TBitMap.Create;
BitMap.LoadFromFile(FileName);
BitMap.PixelFormat:=pf16bit;
BitMap.SaveToFile(FileName);
BitMap.Free;
end;
If you''re converting to 8bit/4bit/1bit mode you might want to write a more complex algorithm as the image is converted using the system palette.
procedure ConvertTo16Bit(FileName:String);
var BitMap:TBitMap;
begin
BitMap:=TBitMap.Create;
BitMap.LoadFromFile(FileName);
BitMap.PixelFormat:=pf16bit;
BitMap.SaveToFile(FileName);
BitMap.Free;
end;
If you''re converting to 8bit/4bit/1bit mode you might want to write a more complex algorithm as the image is converted using the system palette.
I decided to just go with 8-bit images for now, but otherwise the *.TGA file format seems to have what is needed, Photoshop can save it in 16-bit anyway. Only problem is that this file format is more than a tad complicated compared to BMP(see http://www.cubic.org/source/archive/fileform/graphic/tga/tga2.html).
Do anyone know why no programs will save 16-bit BMPs? I mean its part of the file spec, so why not?
But for now 8-bit will have to do the trick, im only learning DirectDraw, to be better able to make good 2D methods later on using 3d accel. in DX8, and as far as i understand DX graphics already has bitmap loading(to textures anyway) included.
As to converting, it seems a damn shame, filling space with 24-bit images when the first thing you do i waste time converting them!(btw, i use C++).
Do anyone know why no programs will save 16-bit BMPs? I mean its part of the file spec, so why not?
But for now 8-bit will have to do the trick, im only learning DirectDraw, to be better able to make good 2D methods later on using 3d accel. in DX8, and as far as i understand DX graphics already has bitmap loading(to textures anyway) included.
As to converting, it seems a damn shame, filling space with 24-bit images when the first thing you do i waste time converting them!(btw, i use C++).
I thought 16 bit wasn''t supported by the BMP format.. I made my own routine a couple of weeks ago for loading bitmaps. I load 24 bit and then convert them to 16 bit 565 format for internal storing.. I convert like this
RGB_16BIT565(r/8,g/4,b/8)
where r,g,b are the 24 bit colors ranging from 0-255..
this isn''t a very accurate conversion is it? it works though.
But strangely.. even though my gfx card uses 565 format, win98 uses 555.. have to convert my 565 to 555 when I want to display them in a dibsection created by passing 16 as the depth in the win32 BITMAP struct.. is this dependant on the current screen mode windows uses?..
If your game reads BMPs directly, why don''t you just write a converter which takes a 24 bit bmp and save it as 16 bit, whether it is supported or not.. that is quite easy and you don''t have to modify the bmp format :-)
RGB_16BIT565(r/8,g/4,b/8)
where r,g,b are the 24 bit colors ranging from 0-255..
this isn''t a very accurate conversion is it? it works though.
But strangely.. even though my gfx card uses 565 format, win98 uses 555.. have to convert my 565 to 555 when I want to display them in a dibsection created by passing 16 as the depth in the win32 BITMAP struct.. is this dependant on the current screen mode windows uses?..
If your game reads BMPs directly, why don''t you just write a converter which takes a 24 bit bmp and save it as 16 bit, whether it is supported or not.. that is quite easy and you don''t have to modify the bmp format :-)
What gets me about the whole thing is that tons of people whine and complain about wanting 16bit functions and stuff. Hell, there are articles in the reference section of Gamedev devoted to dealing with 16bit stuff.
But I run into the same problems as everyone else. No apps support 16bit. I can set me screen res to 16bit - but can''t find any 16bit pictures. Whole chapters of books are written with 16bit in mind - yet there are few, if any, resources for MAKING a 16bit bmp.
my 2cp
Landsknecht
But I run into the same problems as everyone else. No apps support 16bit. I can set me screen res to 16bit - but can''t find any 16bit pictures. Whole chapters of books are written with 16bit in mind - yet there are few, if any, resources for MAKING a 16bit bmp.
my 2cp
Landsknecht
My sig used to be, "God was my co-pilot but we crashed in the mountains and I had to eat him..."
But folks whinned and I had to change it.
But folks whinned and I had to change it.
February 06, 2002 03:37 AM
If you use a half decent paint program like Paint Shop Pro or Photoshop they will export 16-bit pixel data into bmp''s or tga''s or whatever you want.
Check out the MSDN or http://www.wotsit.org/
Standard .bmp files are usually 1, 2, 4, 8, 16 or 24 bits but using the latest bitmap headers you can save 32-bit bitmaps, RLE compressed and even jpeg or png compressed formats. (within the bmp structure not as .jpg or .png files)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_7c36.asp
Check out the MSDN or http://www.wotsit.org/
Standard .bmp files are usually 1, 2, 4, 8, 16 or 24 bits but using the latest bitmap headers you can save 32-bit bitmaps, RLE compressed and even jpeg or png compressed formats. (within the bmp structure not as .jpg or .png files)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_7c36.asp
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement