Search code examples
javaimagejavax.imageioimage-compressionrun-length-encoding

Java Bitmap RLE8 format


Does Java ImageIO (or any other image handlers) support BI_RLE8 image format? The only thing I have managed to find is BMPImageWriteParam but I have no idea whatsoever how to use that. Any help would be wonderful.


Solution

  • See this example for how to write using ImageWriter and using ImageWriteParam (use an instance of BMPImageWriteParam in your case). Scroll a bit down to find the write example.

    Instead of the line:

    ImageWriteParam param = writer.getDefaultWriteParam();
    

    You should insert something like:

    BMPImageWriteParam param = new BMPImageWriteParam();
    param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
    param.setCompressionType("BI_RLE8");
    

    You can safely pass null for thumbnails and metadata (... in the example).