Skip to content Skip to sidebar Skip to footer

Bitmap Pixel Values Differ After Setpixel() And Getpixel() On Same Pixel

I'm developing a steganography app for a class project which allows a user to encode a secret message image with in another image. I use Bitmap.getPixel(x,y) to retrieve pixel info

Solution 1:

This defect in the android api appears to relate to the same issue i'm having. Since there was no way to solve this issue while creating the bitmap from a pixel array or when decoding into the message image I've had to resort to using image filtering after the image has been decoded. I'm using a median filter that has been modified to target problem pixels here is an example of an image with and without the median filter.

unfiltered

unfiltered

filtered

filtered

Solution 2:

This looks very much like an issue I had where (only on some devices) bitmaps loaded from the drawables folder would be changed slightly. I solved it by putting the bitmaps in the "raw" folder (e.g. res\raw). Hope that helps.

Solution 3:

Your bitmap is probably set up as 565, i.e. 5 bits for red, 6 for green, 5 for blue. As such, you can only have 32 distinct values for red/blue and 64 for green.

If you need more precision, you need to create an 8888 bitmap.

Example:

Bitmapbitmap= Bitmap.createBitmap(128, 128, Bitmap.Config.ARGB_8888);

Solution 4:

I know this is an old post, but I was able to solve the issue by alternating adding and subtracting 1 from each incorrect byte in the ARGB integer until the least significant bit of each of those bytes was correct. I believe this is the optimally closest the pixel can get while having the least significant bit of each byte correct.

Additionally, I have reported this bug to google.

Post a Comment for "Bitmap Pixel Values Differ After Setpixel() And Getpixel() On Same Pixel"