3

I'm searching for a method to save a small monochrome Bitmap to a 1bpp PNG file. By default, the bitmap.compress(CompressFormat.PNG, 100, os) produces a 32bpp PNG file having only 2 colors, and about twice the size of the same PNG using 1bpp.

I saw a method using BufferedImage and a colour table, but the BufferedImage is not available in Android.

Worst case, I can use the DeflatorOutputStream (which is also half the size of the 32bpp PNG), though I'd rather be using a PNG if possible.

I've also had a quick try at using the PNGJ library, but I can't instantiate the ImageInfo (results in java.lang.NoClassDefFoundError: ar.com.hjg.pngj.ImageInfo, so I believe I have to sort out my classpaths).

Any tips? First choice is to do it without PNGJ, second is with PNGJ. This is my first time using Java & Eclipse, so please excuse my ignorance.

Thanks! -James

  • 1
    If you are using pngj.jar (or, for the case, any external jar library) in Eclipse for Android, see here http://stackoverflow.com/questions/3642928/adding-a-library-jar-to-an-eclipse-android-project – leonbloy Dec 29 '12 at 15:27
  • Thanks leonbloy, that allowed me to use the PNGJ library :) I'd still like to know if it can be done without the need for the extra library. – James Brown Dec 30 '12 at 01:56

0 Answers0