The chr image file format contains a series of bits equivalent to pixels for each tile in the spreadsheet of a rom.
A chr tile is 8x8 pixels, the data for each tile is made up of 128 bits, where the first 64 bits are the first color, the next 64 bits the second color, and where the colors overlap result in the third color, for a total of 4 colors including the background.
tga file, to a series of
uxncli tgachr.rom tgachr/test.tga # will make file tgachr/test.tga.chr
chr viewer. Press
A to invert colors, press
B to toggle
chr modes, press arrows to resize canvas.
uxnemu viewer.rom image20x10.chr # will display the image as a 20x10 spritesheet
Converts an image in
chr format to
Note: on Plan 9 the executable is called
chr2img since it output a standard Plan 9 image instead of BMP.
To build on Linux:
git clone https://git.sr.ht/~rabbits/chr-format cd chr-format ./build.sh
bin/chr2bmp, which can be used by supplying a chr file on stdin and redirecting stdout to the new BMP file.
To convert a monochrome image:
chr2bmp -1 <image.bit >image.bmp
To convert a 4-color image:
chr2bmp -2 <image.chr >image.bmp
bin/chr2bmp -i -w 32 < ../uxn/projects/pictures/ergo100x0c0.bit > ergo.bmp
Here, Uxn's repository has also been cloned in the parent directory, so we can use one of its example pictures.
chr files are raw data, so they do not store the color depth, the width and height, or the palette, so you need to supply these bits of information or use
-w provides the width in tiles and
chr2bmp will work out the height automatically, unless you also give it the height in tiles with
-h. The default width is 44, which is the width that noodle starts with on Uxn's standard screen size.
-2 control the color depth. The default is
-1, aligned with what noodle uses.
-i inverts the image. The default is for pixels of color zero to be white and one is black, again to match noodle.
To convert to other image formats like PNG, you can pipe the output through ImageMagick's
bin/chr2bmp < ../uxn/untitled.bit | convert - untitled.png