0

I am changing 4 pixels of a bitmap in activity1 and in activity2 I want to obtain those particular pixel RGB values but I am getting different values for that what can be the reason? I have saved image in JPEG format from activity1 to gallery and then I got it from gallery to activiy2. After changing type to PNG just 1 of those pixel value remained same other 3 are different. bitmap in activity to I am getting by code mentioned below.

bitmapActivity2 = MediaStore.Images.Media.getBitmap(this.getContentResolver(), imageUri);
imageView.setImageBitmap(bitmapActivity2);

I have tried by taking drawable object but it was not wotking so changed it to this.

Any suggestions or guidance...

Aalap Patel
  • 2,058
  • 2
  • 17
  • 31
  • Yep, that'll happen. The `MediaStore` Provider [compresses inserted images at 50% quality](https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/provider/MediaStore.java#967). You should instead save the image to storage yourself at 100% quality. – Mike M. Mar 28 '16 at 00:35
  • OK thinking the same. But how to do that? Any way around to get image back with 100% quality?? – Aalap Patel Mar 28 '16 at 01:03
  • "But how to do that?" - The line of code I linked demonstrates how. If you want the image in internal storage, you can get an `OutputStream` for the last argument by calling `openFileOutput()` on a `Context`. If you want it accessible by other apps, you can save it to external storage by getting an `OutputStream` on a standard `File` object. – Mike M. Mar 28 '16 at 01:16
  • "Any way around to get image back with 100% quality?" - If you mean, can you get around saving it as a file, possibly. If your image isn't too big, you could pass it as an extra on the `Intent` used to start the second `Activity`, but the size limit on extras is about 1MB total, AFAIK. I would say the file option is the preferable method. – Mike M. Mar 28 '16 at 01:16

0 Answers0