I’ve Image stored in ImageView and after several processes (flip, rotate, fix color, etc) it’s saved back as new file. However, I just realize that when I just load into ImageView and soon after that directly save the result, I got different result. Take a look at attached image for reference.
image source

image result

Here’s how I extract image from ImageView:
String filePath = Environment.getExternalStorageDirectory()
+ File.separator + bufferPath;
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
selectedImage.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(selectedImage.getDrawingCache());
selectedImage.setDrawingCacheEnabled(false);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
imageFile = new File( filePath );
//write the bytes in file
FileOutputStream fo = new FileOutputStream(imageFile);
fo.write(bytes.toByteArray());
Is there any workaround to make resulting image the same as source? different component, maybe?
Hold a backing
Bitmap(originally the source) that you carry out your manipulations on.Use the
ImageViewjust to show thisBitmap– do not manipulate the post-scaled version that is held in theImageView‘s drawing cache.