writing a BMP file

Non-platform specific questions.

writing a BMP file

Postby feral » Thu Jun 26, 2008 1:24 am

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
Last edited by feral on Thu Jun 26, 2008 1:43 am, edited 2 times in total.
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: writing a BMP file

Postby Fuzzy » Thu Jun 26, 2008 1:35 am

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.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: writing a BMP file

Postby feral » Thu Jun 26, 2008 1:44 am

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
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: writing a BMP file

Postby feral » Mon Jun 30, 2008 5:28 am

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.. ?
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: writing a BMP file

Postby Fuzzy » Mon Jun 30, 2008 5:48 am

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!
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron