geopackage-sdk/src/main/java/mil/nga/geopackage/io/BitmapConverter.java
public static byte[] toBytes(Bitmap bitmap, CompressFormat format,
                                 int quality) throws IOException {
        byte[] bytes = null;
        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
        try {
            bitmap.compress(format, quality, byteStream);
            bytes = byteStream.toByteArray();
        } finally {
            byteStream.close();
        }
        return bytes;
    }
public static byte[] toBytes(Bitmap bitmap, CompressFormat format,
                                 int quality) throws IOException {
        byte[] bytes = null;
        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
        try {
            bitmap.compress(format, quality, byteStream);
            bytes = byteStream.toByteArray();
        } finally {
            byteStream.close();
        }
        return bytes;
    }
Compress the bitmap to a byte array

@param bitmap  bitmap image
@param format  compress format
@param quality quality
@return image bytes
@throws IOException upon failure