Img2pok


#1

img2pok

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.
Features:

  • 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)

Install:
Download latest binaries
unzip on a folder and then:

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

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


#2

Just release V0.8.0.0
Fixes:

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


#3

Thanks a ton! That was quick :smiley:


#4

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


#5

: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!


#6

Sounds (pun intended) like a good idea!

Happy new year to you also!


#7

So, about stream format:

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


#8

Yep. Unsigned char.


#9

@HomineLudens

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?


#10

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.


#11

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.


#12

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


#13

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


#14

V 0.9 Fix the problem you reported.


#15

Perfect!!!


#16

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:


#17

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


#18

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


#19

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


#20

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.