BMP2POK graphics conversion tool

Wow. The 4-bit output from GIMP turned out to be tricky to get working.

But now it is working. In native linux.

Just a bit of cleaning up to do & make sure that all sorts of combinations from 1-, 4-, 8- bit input to 1,4,8, output work.

1 Like

BMP2POK now actually works on Win and Linux

4- and 8-bit input images from Photoshop, GIMP etc supported

USAGE:

to make a .c file with 16 color palette (for 110x88 fast 4 -bit mode):
bmp2pok source.bmp -4
to make a .c file with 4 color palette (for 220x176 hires 2- bitmode):
bmp2pok source.bmp -2

attention
switch -p is not needed / working, palette is always created
1-bit files (monochrome bitmaps) are not yet supported, but will come soon

TRY IT! COMMENT!

1 Like

Sorry to report again there are some issue :disappointed:
I think from the Repo thereā€™s a bug on line 24 on common.cpp that prevent compiling.

Even fixing it, I canā€™t export bmp from gimp to c file. The file is the same Iā€™ve already posted before.

Ok. I will check. I was last working on the win version, maybe I broke something

1 Like

So I couldnā€™t resist to write my own exporter :grimacing:

Uploadingā€¦

It take any picture (png,gif,bmp,jpg,tiff) and extract a palette of color used. Then build the c file.
It now works with 2bit (4 color) but I could expand to others format.
It was instructive to understand the pokitto image format, but is there any doc about?

2 Likes

I will write a wiki about the format. Canā€™t wait to try your converter. For some reason it is stuck at ā€œUploadingā€¦ā€ ?

Here some screenshots

Itā€™s just a WIP and error handling is missing, so Iā€™ll need some time to finish it.

3 Likes

Hahaha! i love it! Love the wonky image as well.

Looks good. BTW the reason why the ccc4colors didnt work is because it is 1 bit. But in any case I fixed the errors and updated the github.

Now it can extract an index palette (based on frequency of colors used), still very raw. Output correctly for 2-4 bit mode. 1 bit to test.

Exe can be downloaded here https://www.dropbox.com/s/jld77sntpkfj2gn/img2pok.exe?dl=0
is Net 4.5.2 in Win10 you need anything else. Use small images, as the process is not optimized yet.
Will push a repo if anyone need.

2 Likes

I like your app but would it be possible to read the palette from the bmp file and use that, rather than the order the colours are found in the image?

I;m trying to convert a 12x216 image, but itā€™s coming out wonky. I know .bmp files require padding to multiples of 8, could this be causing an issue with the conversion?

1 Like

Padding should not be an issue.

Could you send image ? pokittodev @ gmail.com

I have completely refactored BMP2POK. I will make it into a batch-processing command line tool for converting a big bunch of files at once.

I have just now tested 8-bit to 4-bit conversion, 4-bit to 4-bit output, 4-bit to 2- bit output, 1-bit to 4-bit output etc. In windows.

Linux binary needs to be built again.

But it really-diddle-oo should work now.

I opened up your image in GIMP, and added the black/white pattern you see on top to identify the data in the hex editor

Then I saved

Works 100%.

I am now looking at your original file to understand what (yet another) gimmick the BMP format allows

What drawing program did you use?

Edit: yep, I think I see the problemā€¦

It was probably mentioned before, but it would be good to allow bmp2pok to convert a bunch of bmp files into a single .c file by including a folder or *.bmp parameter and have it split into tiles inside .c (similar to what we are doing on the rogue like).

This is helpful, because it is much easier to save each tile as its separate file, than to modify the .c file so each tile is itā€™s own array. (hope that makes sense)

1 Like

Totally agree. That is actually why I am refactoring the code.

There will be a better GUI-based thing for single files, BMP2POK will become a batch-processing tool like you described

1 Like

@spinal yes, I can do. Also save the palette to json file and allow load from there. Also Iā€™d like to export multiple tiles from a single bmp. Probably Iā€™ll make multiple img variables named ā€œpic_file_name_row_columnā€.

Argh. It was not the padding. But it was the ā€œnot divisible by 8ā€ afterall.

Yep, so padding works in a different way in 4-bit source images. My bad.

Cool. Thanks for looking into it.

I just converted your TileSet.bmp in both windows and linux & ran in the sim at 16-colors (110x88 mode) succesfully. Command : bmp2pok TileSet -4

Problem was that padding in 4-bit and padding in 8-bit BMP source files work slightly differently