i'm developing an app i which users can upload images from the camera to an event, i did it in the usual way, but when i got to the part of rotating it according to the Exif interface i would sometimes get OOM errors, which were really frustrating, i decided to try and use JniBitmapOperations library which seemed to work fine (i wouldn't get OOM errors) but when trying to rotate the image it gets corrupt and messed up :/ heres pictures
as you can see the picture above is rotated to the correct position but is all corrupt the one below is the original
here is the part of the code that is relevant:
Options options = new Options();
options.inJustDecodeBounds = true;
options.inPreferredConfig = Config.ARGB_8888;
Bitmap srcBitmap = BitmapFactory.decodeFile(tempImageFilePath, options);
options.inSampleSize = calculateInSampleSize(options);
options.inJustDecodeBounds = false;
srcBitmap = BitmapFactory.decodeFile(tempImageFilePath, options);
ImageLoader.getInstance().clearMemoryCache();
ImageLoader.getInstance().clearDiscCache();
final JniBitmapHolder bitmapHolder = new JniBitmapHolder(srcBitmap);
//if we comment this part out, the image comes out fine but not rotated correctly
switch (angleFix) {
case 90:
bitmapHolder.rotateBitmapCw90();
break;
case 180:
bitmapHolder.rotateBitmapCw90();
bitmapHolder.rotateBitmapCw90();
break;
case 270:
bitmapHolder.rotateBitmapCcw90();
break;
}
srcBitmap = bitmapHolder.getBitmapAndFree();
//this is the old way which caused OOM errors occasionally
// Bitmap.createBitmap(srcBitmap, 0, 0, srcBitmap.getWidth(), srcBitmap.getHeight(), m, true);
try {
FileOutputStream out = new FileOutputStream(tempImageFilePath);
srcBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
if (srcBitmap != null) {
GetImageUploadUrl getUrl = new GetImageUploadUrl();
getUrl.execute();
}
}
}
i would appreciate any help!