[android] Fix PNG compression with different BitmapConfig

Source: https://stackoverflow.com/a/6140360
This commit is contained in:
Torsten Grote
2019-10-23 10:41:37 -03:00
committed by akwizgran
parent 62970cce30
commit c7a0f794c8

View File

@@ -172,6 +172,8 @@ class AttachmentCreationTask {
LOG.info("Scaling attachment by factor of " + inSampleSize);
Options options = new Options();
options.inSampleSize = inSampleSize;
if (contentType.equals("image/png"))
options.inPreferredConfig = Bitmap.Config.RGB_565;
Bitmap bitmap = decodeStream(is, null, options);
if (bitmap == null) throw new IOException();
return bitmap;