How was this bitmap converted to .bin and .pal (pallet) ?

Started by hfheatherfox07, March 28, 2012, 02:00:01 AM

Previous topic - Next topic

hfheatherfox07

Hi...this is the res from a MASM example ...the ,bin and .pal were converted to an .inc file with the tool in the MASM package ....
But How was this bitmap converted to .bin and .pal (pallet) ... I found a few tools from the same author but it wont work.....
this is a long shot that some one came across this before   :wink

hfheatherfox07

Here is what that res is used for ...still need help  :(


mineiro

Inside bmp images (a structure), have informations about height,widht....
Maybe "wotsit" site can help you.

dedndave

in days of old, BMP files were very simple
in the simplest form, the image data was uncompressed, which made them easy to write code for
it also makes for big files   :P
as time went on, they added new versions of the BITMAPINFOHEADER structure, and they became a bit more complex
the format is important to know - DIB's, ICO's, CUR's all use formats based on the old BMP files

a lot depends on what type of BMP file you want to work with
if it is uncompressed and does not support transparency, it is reasonably simple:

you can find these structures in windows.inc...
BITMAPFILEHEADER
BITMAPINFOHEADER

after that, there may be a color table, commonly refered to as a palette
palettes are used for images that support 256 colors or less
for those types of images, each color has an RGBQUAD, and the image data indexes into the palette
for images that support more colors, there is no palette, as the image data holds a complete RGBTRIPLET for each pixel

here are a couple links that may help...
http://msdn.microsoft.com/en-us/library/dd183391%28v=vs.85%29.aspx
http://en.wikipedia.org/wiki/BMP_file_format

dedndave

the image you have in bitmap.inc example is a 16-color image - pretty simple

one program i recommend is Mael Horz's HxD  :U
http://mh-nexus.de/en/hxd/
it will let you look at the file in hex form to see what is going on

the sov.bmp file has a BITMAPFILEHEADER (always 14 bytes), BITMAPINFOHEADER (40 bytes), palette (64 bytes), and the image data
microsoft stores everything upside down and some stuff backwards - lol
for example, bytes in the RGBQUAD and RGBTRIPLET structures are stored in BGR order
the image data is typically stored left-to right, starting with the bottom line of the image
although, if the height value in the header is negative (word), the image data starts with the top line
if it is negative, the image cannot be compressed  :dazzled:
poor engineering in my opinion - you can compress and uncompress data in one direction as well as the other

BMP image lines are always a multiple of 4 bytes in length, so they may pad the ends of the line, usually with 0's

for 16-color images, each byte in the image data area holds indexes for 2 pixels
the upper nibble is the left pixel and the lower nibble is the right pixel
so, if the byte is 6Fh, the left pixel uses palette entry 6 (zero-based) and the right pixel uses palette entry 15

it looks to me as though they simply seperated the parts of the BMP file to create the PAL and BIN files

BITMAPFILEHEADER structure
http://msdn.microsoft.com/en-us/library/dd183374%28v=vs.85%29.aspx

BITMAPINFOHEADER structure
http://msdn.microsoft.com/en-us/library/dd183376%28v=vs.85%29.aspx

RGBQUAD structure
http://msdn.microsoft.com/en-us/library/dd162938%28v=vs.85%29.aspx

hfheatherfox07

Thank you all ....
....I found a solution....Since I started this thread  Here I will as well post the solution here .....
a programmer on another forum whipped a utility up in C++

.... SO here is a few MASM examples and how to used it .....also with 2 modules and run.bats from Generalised Bitmap Module  http://www.nyangau.org/gbm/gbm.htm
To convert the images ...they need to be :


4 Bits Per Pixel
Dimensions: 32 x 32
Size: 512
Entries in colour table: 16 ( 16 colours in the pallet )


a Photoshop software will give you nicer images but if you do not have it that all you need is included .....
Thanks to ghandi for making this utility

Enjoy the Graphics