0

I want to draw a bitmap, but with only gray pixel (for example 0x555555 color).

So I should change all the colorful pixel's color to gray.

How to do this or how to draw an image with only grayed pixels?

Alexander Farber
  • 18,345
  • 68
  • 208
  • 375
Adem
  • 9,146
  • 8
  • 39
  • 57

2 Answers2

1

What you are looking for is called "converting image to grayscale in English". Making a simple search I found the following thread (luckily it targets exactly Android. Hopefully it will help you.

Community
  • 1
  • 1
Boris Strandjev
  • 43,262
  • 13
  • 98
  • 123
0

You can read every pixel, convert it to RGB color system. Then if you want grey, then Red, Green and Blue must have equal value.

I don't know exactly what is best, when you get the good "gray" color. But maybe if you do this math: (Red + Green + Blue) / 3 = x Color R = x, G = x, B = x; Then they all got the same color, but I don't know if yo get a correct gray scale with this.

If you need more information, just say it, I got some code how to read pixels from a bitmap and convert them into RGB color system.

Bigflow
  • 3,526
  • 5
  • 26
  • 52
  • 2
    This is not the best formula for converting to grayscale. The most common formula is: (red*0.3 + green*0.59 + blue*0.11). See here for example: http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale – Boris Strandjev Mar 05 '12 at 15:34