4BS sprite/pallet converter for png, tga, bmp, psd

4 bit sprite converter can convert from popular lossless file formats

  • .PNG
  • .BMP windows bitmap
  • .TGA targa file
  • .PSD photoshop file

mac version
linux version
windows version

how to use:
using your own pallet with a 1x16px image
./4BS yoursprite.png 1x16pallet.png

or if you want to use pico8 colors
./4BS yoursprite.png

examples of pallet files

still a work in progress it will just give you an output.4BS file

few bugs to mention, sprite width has to be even or else there is miss alignment, dont have an easy fix for it just add a pixel and id sude work
the other thing is const char sprite[] also not sure what im doing wrong in the simulator but this has to be const uint8_t sprite[] i will try and patch that in on a new release soon, will also open up the code wen i clean it up

code now on github


i will release the source code today, but i have a logic problem i cant seem to figure out
so to generate a pallet from an image i need to parse the hole image and get 16 colors
i got the theory but the code just spits out the same value to all 16

char dex = 1;
pallet[0] =  img[0];
for(int i = 0; i <w*h; i++){
    short color565 = img[i];
    for(int j = 0;j < dex; j++){
        if(pallet[j] == color565){
        // sommething something add to dex add to pallet

codes on github now its not much to look at
tinker with it and consider to help improve it

I don’t know how much help this will be. A few years ago I played around with image colour reduction.
Basically I recorded every single Colour, sorted them then simply chose every x colour number for the palette. Not perfect by any means, but it did a really good job for 256 colours. Not sure about 16 colours.

thx but i think the new version of bmp2pok has well overtaken my simple converter