💾 Archived View for gemini.sensorstation.co › computing.uxn.utils.indexed-to-chr.gmi captured on 2022-06-11 at 20:35:45. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-11-30)
-=-=-=-=-=-=-
This Python script converts an indexed image to the 2-bits-per-pixel "chr" format used by the Uxn emulator's PPU.
0x00 0x00 0x01 0x01 0x02 0x02 0x03 0x03 ... └──────────────────┬──────────────────┘ ▼ 0b00110011 0b00001111
Using GIMP, open your image and change the color mode to indexed by selecting "Image → Mode → Indexed...". Then, select either "Generate optimum palette" with a maximum of 4 colors, or "Use a custom palette" and select a palette you have created with exactly four colors.
Then export your raw image data by selecting "File → Export..." and at the bottom of the file dialog, select a file type of "Raw image data". After exporting, you will have two files. The file with a .data extension contains the indexed pixel color data starting from the top left corner, one byte per pixel (color one is 0x00, color two is 0x01, color three is 0x02, color four is 0x03). The second with a .pal extension indicates the palette used for each color; the first three bytes indicate the RGB components for color one, the next three bytes for color two, and so on.
The image dimensions must be evenly divisible by 8, the dimensions of a sprite.
./indexed-to-chr.py [input] [output] [width] ./indexed-to-chr.py input.data output.chr 12
Compudanzas has an excellent tutorial explaining sprite usage in Uxn.