Search code examples
javaimage-compression

How to compress three-color pictures efficiently


In my applicaiton, there are many two-color and three-color pictures. Two-color pictures are black and white, I convert the picture into monochrome mode, from 8-bit to 1-bit. Three-color pictures are black, white and red. Is there a similar mechasim to convert the picture into 2-bit?


Solution

  • Seems you're looking for an indexed color storage model, with 2-bit index values, so each byte stores 4 pixels.

    From the linked Wikipedia article:

    indexed color

    A 2-bit indexed color image. The color of each pixel is represented by a number; each number (the index) corresponds to a color in the color table (the palette).