spritely icon indicating copy to clipboard operation
spritely copied to clipboard

Allow color palette to be defined by a file

Open dfirebaugh opened this issue 6 years ago • 4 comments

It would be nice if the user could configure their own color palette.

Eventually we can add color selector to the gui.

For now, could we optionally import a file that contains the rgb values for our 16 colors? If the file doesn't exist when we start the app, default to the original color palette.

How can we handle this cleanly when importing a saved spritesheet? Can we add the color palette information inside the png file?

dfirebaugh avatar Oct 09 '20 05:10 dfirebaugh

I haven't tried it myself, but I've heard that you can pack all kinds of metadata into png files beyond the basic pixel data. That's how, for instance, Pico8 is able to embed the entire game cartridge info into just the one png.

jamessral avatar Oct 13 '20 21:10 jamessral

yeah, steganography! That would be cool if it's practical.

dfirebaugh avatar Oct 14 '20 01:10 dfirebaugh

@dfirebaugh I would like to tackle this issue. Could you please assign it to me?

tom-vthptvh avatar Oct 27 '20 18:10 tom-vthptvh

@dfirebaugh Could you take a look at the idea?

  1. Color palette file:
  • Name: palette.cfg
  • Format: Text file
    • 16 lines of RGB color value in decimal
    • Top down order, left-to-right corresponding to the 4x4 color palette
r,g,b
r,g,b
r,g,b
r,g,b
r,g,b
r,g,b
r,g,b
r,g,b
r,g,b
r,g,b
r,g,b
r,g,b
r,g,b
r,g,b
r,g,b
r,g,b
  1. Embedding the color palette information when saving png file
  • Append color palette information (in binary format) to the PNG file
  • Format: binary
Byte size Description
8 Header, fixed as "SPRITELY"
48 Array of 16 (R,G,B) values
1 Simple checksum: xor all 48 data bytes

tom-vthptvh avatar Oct 31 '20 03:10 tom-vthptvh