Page 1 of 1

writing a BMP file

PostPosted: Thu Jun 26, 2008 1:24 am
by feral
is there any examples of how to write a bmp file out to disk ?

I understand how they are read, and I can open them and manipulate the pixel data and display it on screen no problems , but i am at a loss on how to export the changed data, especially if i changed the SIZE of the bmp.. ( i can do the data part, it is the header that is confusing)

I am working on this..
based on game a gogos/pyrometals rotation code
spriter.jpg

so far ,

1. I can open up ANY sized 24 bit bitmap (in multiples of four) and the program automatically adjusts for size
(I know how to solve the multiples of four problem.. just haven't got to that point yet.)
2. the program reads the first pixel and turns all others of the same color to "transparent" and then fills in the corners created by each the rotation with the same color.. it will also enlarge the bitmap area to encompass complete rotations without cropping
3. loads by filename prompt and error checks if exist - note: can load from other directories as long as you know the path
4. then rotates image as many times as asked, and assembles a spritesheet in a bitmap ready array (pixel data array)

I only need to know how to finish writing it out ie: how to do the BMP header ! I can do the data part OK..

thanks in advance
feral

Re: writing a BMP file

PostPosted: Thu Jun 26, 2008 1:35 am
by Fuzzy
I looked over BMP years ago and discarded it. the compression and variations of format are just a pain in the butt. What I did was make a TGA loader/saver. Its much simpler in format.

Re: writing a BMP file

PostPosted: Thu Jun 26, 2008 1:44 am
by feral
Fuzzy wrote:I looked over BMP years ago and discarded it. the compression and variations of format are just a pain in the butt. What I did was make a TGA loader/saver. Its much simpler in format.



sounds good to me... any examples ?
I found the TGA loader script.. but not how to save :(

feral

Re: writing a BMP file

PostPosted: Mon Jun 30, 2008 5:28 am
by feral
i have figured out how to do a bitmap loader/saver for any sized 24 bit bitmap and will post a demo soonish..

in the meantime this question can be closed...

cheers
feral
pS: unless someone knows how to open and read and save in PNG and or TGA, so i can work with transparencies as well.. ?

Re: writing a BMP file

PostPosted: Mon Jun 30, 2008 5:48 am
by Fuzzy
PNG is horribly complicated. I looked into that too.

Let me dig up or write a better TGA loader/saver. Just need a little time!