GP32 Bmp2c


Dalto

Certified Guru
Joined
Jun 13, 2004
Messages
266
Location
Just north of Mexico
Website
Visit site
EDIT: New name, new features and new download locations in later post below.

Orginal Post:
After being frequently thwarted by the bmp2bin/raw2c mechanism. I wrote my own bmp to c array converter.

The main advantages of this converter are:
  • A single program to run, no intermediary raw file is needed.
  • Supports many types of bitmaps including: 1,4,8,16,24 and 32 bit as well as RLE4 and RLE8 encoded BMP's
  • Supports three types of output files: Rotated for the Gamepark SDK, Non-rotated for Mirko's SDK and including the header for Mirko's SDK
Please let me know if you have any problems with these or any enhancements you would like to see.
 
Does this just remove the header from the file, and turn it into an array? Because remember, bitmap images are 4 byte aligned. So if you don't remove the padding at the end of a line, you'll need to do this in your program. I had GP32Converter, which didn't do that, but I didn't know. So I cracked my skull open trying to figure out why my 24x24 images were drawn properly, but my other images wern't... I finally figured it out though, and switched to Aquafish's converter, which did remove the padding.
 
Tristan posted on Aug 6 2004 at 07:29 AM said:
Does this just remove the header from the file, and turn it into an array? Because remember, bitmap images are 4 byte aligned. So if you don't remove the padding at the end of a line, you'll need to do this in your program. I had GP32Converter, which didn't do that, but I didn't know. So I cracked my skull open trying to figure out why my 24x24 images were drawn properly, but my other images wern't... I finally figured it out though, and switched to Aquafish's converter, which did remove the padding.
Actually, each type of BMP is padded differently, the BMP standard is rather amusing. This handles interpreting the padding and encoding used by all BMP's. However, if you find one it doesn't handle, send it to me and I can probably fix it.

EDIT: By it, I mean my software of course :)
 
Last edited by a moderator:
Updated with new features and a new name: imageconverter

Features:
Support for reading many types of BMP files including: 1, 4, 8, 16, 24 and 32 bit as well as REL4 and RLE8 encoded BMPs
new! Support for reading interlaced and non-interlaced GIF files
new! Support for the color palette of the gp32 and the gba
Support for rotated and non-rotated images
Support for MR Mirko's header files
new! Support for output to raw 16 bit image data
Support for output to c arrays

You can get it here.
 
Dalto posted on Aug 8 2004 at 07:22 PM said:
Updated with new features and a new name: imageconverter

Features:
Support for reading many types of BMP files including: 1, 4, 8, 16, 24 and 32 bit as well as REL4 and RLE8 encoded BMPs
new! Support for reading interlaced and non-interlaced GIF files
new! Support for the color palette of the gp32 and the gba
Support for rotated and non-rotated images
Support for MR Mirko's header files
new! Support for output to raw 16 bit image data
Support for output to c arrays

You can get it for windows from here: http://www.gp32.us/imageconverter.exe
You can get it for linux from here: http://www.gp32.us/imageconverter
Had a quick look at your converter program.
Please support the latest header version ( 0.85 SDK version )

typedef struct {
char magic[4]; // "MR.M"
u16 size_x; // x size of sprite
u16 size_y; // y size of sprite
u16 reserved1; // User usable
u16 reserved2; // User usable
} SHEADER;

So the header is 12 Bytes long, thanx for this nice program...
I think it will help a lot Windows users ...
 
Last edited by a moderator:
mr.mirko posted on Aug 9 2004 at 09:54 PM said:
Dalto posted on Aug 8 2004 at 07:22 PM said:
Updated with new features and a new name: imageconverter

Features:
Support for reading many types of BMP files including: 1, 4, 8, 16, 24 and 32 bit as well as REL4 and RLE8 encoded BMPs
new! Support for reading interlaced and non-interlaced GIF files
new! Support for the color palette of the gp32 and the gba
Support for rotated and non-rotated images
Support for MR Mirko's header files
new! Support for output to raw 16 bit image data
Support for output to c arrays

You can get it for windows from here: http://www.gp32.us/imageconverter.exe
You can get it for linux from here: http://www.gp32.us/imageconverter
Had a quick look at your converter program.
Please support the latest header version ( 0.85 SDK version )

typedef struct {
char magic[4]; // "MR.M"
u16 size_x; // x size of sprite
u16 size_y; // y size of sprite
u16 reserved1; // User usable
u16 reserved2; // User usable
} SHEADER;

So the header is 12 Bytes long, thanx for this nice program...
I think it will help a lot Windows users ...
Mr. Mirko, using that header in your latest sdk I cant seem to figure out how to tell which number in your array is the width and height of image. Is there a way to tell?

Anyway great program. This is definately gonna come in handy as you dont have to have so many .raw files everywhere.
 
Last edited by a moderator:
CrazyDesi posted on Aug 10 2004 at 01:52 AM said:
Mr. Mirko, using that header in your latest sdk I cant seem to figure out how to tell which number in your array is the width and height of image. Is there a way to tell?
If you are looking at the actual text representation of the array it is not all that easy. The width is the 5th and 6th values, the height is the 7th and 8th values.

Now, they are stored in little endian format for the byte order is reversed. So, the easiest thing to do is convert them both to hex and then put them together backwards then back to decimal.

Let me demostrate:

{ 54, 76, 34, 23, 45, 05, 65, 01, ......}

5: 45
6: 05
7: 65
8: 01

In hex
5: 2D
6: 05
7: 41
8: 01

Width: 052D=1325, Height 0141=321

This is MUCH easier to do in code. Assuming you image array is named monkey, just do this:

width=*((u16)monkey+2);
height=*((u16)monkey+3);
 
Last edited by a moderator:
New Version!

1.0 Beta Released. I strongly recommend switching to this version if you are using Image Converter.

Changes:
Made arrays const
Made arrays unsigned shorts
Changed array output to be hex instead of decimal for readability
Added option for limiting output line width for ease of editing, -w
Updated Mr. Mirko's header to the latest version
Fixed a bug when using -o with -c
Fixed a bug that caused -g and -a to be reported as invalid


You can get it here: http://www.gp32.us/imageconverter-v1-beta.zip
 
Back
Top