0

I developed an application that is able to recognize the color of a selected image area. It works perfectly for Android 2.2. Now I'm trying to use it on devices 2.3. To make it work properly on 2.2 I had to overcome many problems caused by dithering, and the format of the bits of the screen. Now I have the same problem for 2.3 and I do not know what to invent.

color = mBitmap.getPixel((int)event.getX(), (int)event.getY());

Does not see color differences very small.

user1169390
  • 151
  • 11

2 Answers2

2

The discussion leads me to believe (e.g. "I see a single value greater than both") that you're mathematically comparing an ARGB value to an RGBA value, or something like that. Know you're encoding, particularly which byte holds the "alpha" component, and compare the color components, not the 32-bit value.

CSmith
  • 13,318
  • 3
  • 39
  • 42
  • Exactly. The screen is RGBA and the bitmap is ARGB. In version 2.2 will still work. I also understand what you mean, but I have no idea how to do. You can get some links? thank you – user1169390 Feb 02 '12 at 15:35
  • 1
    For ARGB, you have A=first 8 bits, R=second 8 bits, G=third 8 bits, B=last 8 bits. For RGBA, A=last 8 bits, etc... Extract the component colors (each will be an 8-bit number, i.e. 256 colors) and compare them. – CSmith Feb 02 '12 at 17:33
0

what if you use a moving average filter on the image to check nearby pixels, this could help with the dither.

L7ColWinters
  • 1,342
  • 1
  • 14
  • 31
  • Maybe I did not understand your answer, but in any case it is better that I make a clarification. The pixels in a selected area are all the same color. the problem is that two areas with two different shades of gray are seen as having the same color. – user1169390 Feb 02 '12 at 14:44
  • http://www.mail-archive.com/android-developers@googlegroups.com/msg38890.html converts bitmap to greyscale and from that you could see if there is any difference? – L7ColWinters Feb 02 '12 at 14:52
  • I do not I create programmatically but with photoshop. Two colors of gray neighbors I see them as a single value greater than both. – user1169390 Feb 02 '12 at 15:10