How can I compress and add an image with the standard version of the Android SDK?

Q:

I want to add an image to a page using the standard version of the Android SDK. The image is uncompressed, and the PDF document size increases a lot. The full version of the SDK allows you to compress the image data, and thus the PDF document doesn’t increase very much. How can I get the same functionality with the standard Android SDK?

A:

One workaround would be to compress the image data with Flate (java.util.zip.Deflater), then pass the compressed data into Image.Create:

https://www.pdftron.com/pdfnet/mobile/docs/Android/pdftron/PDF/Image.html#create(pdftron.SDF.Doc, byte[], int, int, int, pdftron.PDF.ColorSpace, int)