RGBA8888 to RGB332

rgba8888-to-rgb332 is a cli tool that will process all files found in an input folder, transforming them from a file format containing full 16 million color PNG files to 8-bit raw data files. This is accomplished using a restrictive palette. Transparent pixels can be replaced with a specified color.

Purpose

The RGB332 raw file outputs are useful for developing software using embedded graphics, where an 8-bit color palette can reduce memory usage drastically and adhere to certain display requirements.

Color masking is an optional feature provided, granting a way to choose a pixel color to skip when blitting pixels to a buffer. For example, if the color 0b11100011 (hex #ff00ff or #ff00ffff with transparency channel) is chosen, it is simple during development to add that pixel color to a branch statement, and omit drawing it to the screen. This provides the user to implement their own transparency.

Example Usage & Workflow

  1. Review the RGB332 palette, your sprites MUST adhere to these colors strictly.
    1. If you wish to use transparency, you will need to decide on one of the colors from the palette to be reserved as the MASK_COLOR
    2. You may use fully transparent pixels, the RGBA8888 to RGB332 can perform the replacement
  2. Create or export your sprites in PNG format, using RGBA 8888 format (standard 24/32 bit PNG)
  3. Place all your sprites into a single folder
  4. Execute rgba8888-to-rgb332 -i <your_sprite_folder> -o <your_output_folder>
    1. If your sprites used transparent pixels, you must use the -m <mask_color> argument
    2. The mask color must be represented by the format 0b00000000 or 0b000_000_00 for visual separation of the rgb channels
  5. Raw .data files can be found in the output folder specified

Palette

The palette used to map RGBA8888 to RGB332 follows strict rules. For simplicity, it will be described using 8 character HEX color code rules.

Red Channel

```

00__ no red

24__

49__

6d__

92__

b6__

db__

ff__ full red

```

Green Channel

```

00__ no green

24__

49__

6d__

92__

b6__

db__

ff__ full green

```

Blue Channel

```

__00 no blue

__55

__aa

__ff full blue

```

Alpha Channel

```

__00 a fully transparent pixel

__ff a fully opaque pixel

``` Note: When the alpha channel is 00, the first 3 bytes of the pixel are ignored.

Palette Reference

An image containing 1 pixel per color in the RGB332 palette