Page 1 of 2

does any body know a .png or .bmp file configuration?

PostPosted: Wed Jun 13, 2007 12:20 am
by Sgt. Sparky
does any body know a .png or .bmp(8-bit) file configuration?
I have tried using google and yahoo to find it but I cannot,
I am trying to add exporting files as a .png or .bmp depending on which I can figure out or get the configuration for. :D
my current Icon is made with my latest pixel art painting program. :D
http://game-editor.com/forum/tp-3662-Pa ... aker-.html

PostPosted: Wed Jun 13, 2007 2:25 am
by Fuzzy
png is... hard. bmp uses RLE compression.

PostPosted: Wed Jun 13, 2007 11:20 am
by Sgt. Sparky
Fuzzy wrote:png is... hard. bmp uses RLE compression.

I am somwhere near a complete noob when it comes to that,
still:
I need to learn that type of configuration, my paint image reader function can barely load a .bmp(by that I mean the colours are all messed up. :( )
but I only made it to load .paint files(the type I made which are uncompressed.) but I am wanting the ability to export an image as a .bmp, I do not really need to read one.
(all I need are the basic properties of an 8-bit.)

PostPosted: Wed Jun 13, 2007 5:59 pm
by Fuzzy
An uncompressed TGA 24 bit is about as easy as it gets. Try that.

Save one to disk, uncompressed, true color. Crack open your hex editor, and find the X and Y matching values. The other 16 or so bytes you can just copy direct. That does it for the header.

So you copy the 18 bytes at the beginning, replacing the values for the X and Y. After that append your RGB values, but they go in reverse order... BGR. if your image is 16x16, then you need to write 3x256 or 768 bytes after the 18 byte header.

When you go to load one, check the file length. It should be 786 bytes. If it matches, then you can check each element of the header. If they all match up, then read the body of the file(offset 18 from the beginning) to an array or 3 arrays, as you choose.

How about I write a function for read and write later today? I have a specialized one i can modify for you.

PostPosted: Thu Jun 14, 2007 12:23 am
by Game A Gogo
I would help you sgt.sparky.
We could work together! sumer is coming for me (after tomorow) and I am willing to help you :3

PostPosted: Thu Jun 14, 2007 1:47 pm
by Sgt. Sparky
Fuzzy wrote:How about I write a function for read and write later today? I have a specialized one i can modify for you.

that would be Awsome! :D
I am way busy with doing a couple of projects right now,
so that would be very helpful!
I will add you in the credits(I will accually make some this time![I normally do not make them because I am always the only one on my projects. :(]) :D

PostPosted: Thu Jun 14, 2007 6:09 pm
by Fuzzy
I'm typing it out right now. I'll post it to here, rather than making a demo.

PostPosted: Thu Jun 14, 2007 6:30 pm
by Sgt. Sparky
allright, I might not be able to test it for a while.
but can you make a writing sctipt to(or I may be able to figure it out because writing is pretty much the opposite of reading with some mods.)? :D
oh,
and I will put an opening credit towards you(for making the function),
what would you like your name to show up as?

PostPosted: Thu Jun 14, 2007 6:36 pm
by Sgt. Sparky
Game A Gogo wrote:I would help you sgt.sparky.
We could work together! sumer is coming for me (after tomorow) and I am willing to help you :3

I would be glad for the help but I am quite busy. :(
what part would you like to help with?

PostPosted: Thu Jun 14, 2007 11:18 pm
by Game A Gogo
saving the files?
I'm going to check for reference, if I was able to write a wav file, I'm sure I will be able to read/write a bmp and a png.

I know bmp are written backwards also :P thats why it loads from teh bottom on the internet

PostPosted: Tue Jun 19, 2007 5:23 am
by Sgt. Sparky
Game A Gogo wrote:saving the files?
I'm going to check for reference, if I was able to write a wav file, I'm sure I will be able to read/write a bmp and a png.

I know bmp are written backwards also :P thats why it loads from teh bottom on the internet

the wave file did not work though. :(

PostPosted: Tue Jun 19, 2007 10:30 am
by DocRabbit
Here is a link to a good explanation of the .bmp structure if this will help any.

http://www.fortunecity.com/skyscraper/w ... ffrmt.html

PostPosted: Tue Jun 19, 2007 1:31 pm
by morcior
256-Color Bitmap is an pretty easy format to write and load, and no it does not use compression.

The file structure is a header, then an array of RGBA components (4 bytes), and finally the picture array as an array of 1-byte color references. The link above describes it perfectly.

Recreate the BITMAPFILEHEADER and BITMAPINFOHEADER structs in GE (you'll find c++ code for this with a quick search, or construct them yourself using the data from the above link).

Then its simply a case of populating the structs, dumping them to file, writing your color table (you'll probably want to write this table out manaully to a standard 256-color palette and use the same for each image), dumping that to file, and then dump your image as 1-byte color table references.

PostPosted: Tue Jun 19, 2007 6:45 pm
by Sgt. Sparky
thank you, I may give that a try in a week or so(I just moved and alot of family and friends are coming to visit.)
:D

PostPosted: Wed Jun 20, 2007 2:00 am
by Game A Gogo
Sgt. Sparky wrote:
Game A Gogo wrote:saving the files?
I'm going to check for reference, if I was able to write a wav file, I'm sure I will be able to read/write a bmp and a png.

I know bmp are written backwards also :P thats why it loads from teh bottom on the internet

the wave file did not work though. :(

It did work, its just the 22100Hz has odd behavior.