Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

What are Indexed Colorspaces?

52 sec read

What are indexed Colorspaces?

What are Indexed Colorspaces?

Indexed Colorspaces store a list of the colors used and reference that list to get the color of each pixel, rather than directly referencing each color value for a pixel in an image.

What are indexed Colorspaces?

Why are Indexed Colorspaces useful?

Indexed colorspaces are very useful if you only have a limited number of colors in an image. If you only use 2 colors, you can create a table to store the 24bit color values (6 bytes) and then reference them as a pointer to which value to use (0 or 1) which only needs 1 bits. So each pixel will use a quarter of a byte as opposed to 3 bytes (a file size saving of 24 times which can be a very big number on large images.

If you have less than 16 colors, you need a 4 bit look-up and even if you have 255 colors you will still save 2 bytes for every pixel.

And the disadvantages?

The main disadvantage of indexed colorspaces is that they make reconstructing the image more complicated. They are also less beneficial if the image contains lots of colors.

Some examples of how IndexedColorpaces are used

In Java there is an IndexedImage type or you can use the lookup table to build the original image data. This is also optimised for speed so it is faster and more memory-efficient.

The PDF file format uses IndexedColorspaces to reduce the size of PDF files.

GIF image files use a lookup table to reduce the size of the files created.



Are you a Java Developer working with Image files?

Why do developers choose JDeli over free alternatives?

  1. Works with newer image formats such as AVIF, HEIC, JPEG XL, WEBP
  2. Better support than alternatives for JPEG, PNG, TIFF.
  3. Prevent JVM crashes caused by native code in other image libraries
  4. Better performance than other popular Java image libraries
Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

What is JPEG XL?

Amy Pearson
1 min read

What is JBIG2?

JBIG2 is a lossless and lossy compression standard for bi-level images like scanned documents, offering high compression ratios by identifying and encoding similar shapes...
Amy Pearson
55 sec read