img2pok is a small utility for convert images to an C compatible format for POKITTO

Original inspired to bmp2pok it allows to read a wider range of images format.

  • Load images in common formats (.jpg,.bmp,.png,.tiff)
  • Use image as palette (extract all colors from palette)
  • Extract palette from image (experimental, using simple color distance)
  • Editable palette (add/remove/edit colors, drag and drop to change order)
  • Split image in multiple tiles
  • Import/Export palette as json

Developed in C# using WinForm works in Windows and Linux too (using mono)

Download latest binaries
unzip on a folder and then:

Double click on executable
Require .NET 4.5.2 (usually already installed)

sudo apt-get install mono-runtime
sudo apt-get install libmono-system-windows-forms4.0-cil


Just release V0.8.0.0

  • Extraction of palette with images smaller then 32x32 (thanks @jonne to find it)
  • Using nearest-neighbor in image preview (thanks @trelemar)


Thanks a ton! That was quick :smiley:

1 Like

@HomineLudens Your tool is so good even I am not using my own command line pos anymore ! :grin:


:blush: thanks @jonne too kind from you.
I would like to add a section to convert small sounds to header format, and so enable embeding in the bin something playable by playMusicStream().
Do you think is possible/worth ?

BTW Happy new year!

1 Like

Sounds (pun intended) like a good idea!

Happy new year to you also!

1 Like

So, about stream format:

Correct? Just a big array of bytes for the wave?

Yep. Unsigned char.


Question about img2pok: if I save a .bmp with a defined palette, that has colors that are not used in the bitmap (for example a background color needed in the game palette), those colors are not carried into the palette. Img2pok will only extract colors used in the bitmap itself.

How do you handle this problem yourself? Do you edit the palette file manually or always use a tileset or what is the best way?

Usually I start with a bitmap that contains all the color palette I need and extract all colors from there.
You can edit colors manually by right click on the palette list box.
You can also rearrange palette drag and dropping the colors in the order you prefer. When satisfied I save the palette in json format as reference.

Here how looks a DB16. (RGB + Cunt of pixel (that’s for extracting best palette(maybe I should remove)))

[{"Color":"24, 12, 28","Count":63},{"Color":"84, 129, 213","Count":63},{"Color":"74, 55, 67","Count":127},{"Color":"216, 125, 38","Count":63},{"Color":"46, 50, 110","Count":63},{"Color":"142, 162, 172","Count":63},{"Color":"108, 172, 37","Count":63},{"Color":"135, 69, 48","Count":63},{"Color":"215, 169, 153","Count":63},{"Color":"45, 100, 33","Count":63},{"Color":"104, 196, 206","Count":63},{"Color":"212, 68, 71","Count":63},{"Color":"220, 214, 89","Count":63},{"Color":"109, 106, 90","Count":63},{"Color":"224, 235, 209","Count":63}]

The you can load all the assets you need using that specific palette.
So simply every time you need that palette you can simply reload the json file and convert images

Maybe we could improve the process.

This is my exact process too. I used to think it cared if the image was indexed but I’ve been working with rgb colorspace now with aseprite and it works just great! I have a bunch of different palette json files that take some time to make. Gimps’s palette file format wouldn’t be too hard to replicate.

1 Like

Founding a bug:
If I loaded a 4*4 bmp, Img2pok’s display section shows a weird img.

Thanks to point it out @79859899
It’s just an artifact but very annoying. I think it can be fixed.

V 0.9 Fix the problem you reported.



Any chance of an option to group the data in line if multiple cells are created? like this?

//[24] cell:0x3
8,8,  11,11,11,11,11,11,11,11,  11,11,11,11,5,11,11,11,  5,5,11,5,5,5,5,5,  3,5,5,5,5,3,5,3,  14,3,5,5,3,1,3,4,  14,9,3,3,1,4,4,4,  14,9,9,9,1,4,4,4,  9,9,9,14,4,4,4,1,

Just a personal preference :stuck_out_tongue:

but why ?, can you select parts of it like this ?

Sure. It can be done. Should I use this as default?

Not if i’m the only person asking for it, might be odd for other people.

I’d also like the data grouped, but I’d prefer a format like this:

	8, 8,

	11, 11, 11, 11, 11, 11, 11, 11,
	11, 11, 11, 11, 5, 11, 11, 11,
	5, 5, 11, 5, 5, 5, 5, 5,
	3, 5, 5, 5, 5, 3, 5, 3,
	14, 3, 5, 5, 3, 1, 3, 4,
	14, 9, 3, 3, 1, 4, 4, 4,
	14, 9, 9, 9, 1, 4, 4, 4,
	9, 9, 9, 14, 4, 4, 4, 1,

I’d also lean on the side of making the number hex instead of decimal, but I suspect that’s just me.