I'm trying to scale down an image with a code like this:
bmp = BitmapFactory.decodeFileDescriptor(getContentResolver().openAssetFileDescriptor(imageUri, "r").getFileDescriptor());
Pair<Integer, Integer> dims = getScaledDimensions(longerSide, bmp.getWidth(), bmp.getHeight());
Bitmap smallBmp = Bitmap.createScaledBitmap(bmp, dims.first, dims.second, true);
ByteArrayOutputStream bastream = new ByteArrayOutputStream();
smallBmp.compress(Bitmap.CompressFormat.JPEG, 85, bastream)
barray = bastream.toByteArray();
However with bigger image (8px camera photo scaled to 1920x1440) output is "corrupted" as you can see below (few pixels followed by white area). Small images are sometimes processed correctly. This is issue on the Nexus 5, 5.0.1 phone and emulator.
I've elaborated with image size, disabled some relatively expensive memory operations of my app etc, but nothing helped.
Does anyone have an idea what's the cause? Thank you.