1 Bitmap bitmapOrg = BitmapFactory.decodeByteArray(rawData, 0, rawData.length); 2 Bitmap bitmapNew = bitmapOrg.copy(Config.ARGB_8888, true); 3 if(bitmapNew == null) 4 return; 5 for(int i = 0;i<bitmapNew.getWidth();i++) 6 { 7 for(int j =0;j<bitmapNew.getHeight();j++) 8 { 9 int col = bitmapNew.getPixel(i, j); 10 int alpha = col&0xFF000000; 11 int red = (col&0x00FF0000)>>16; 12 int green = (col&0x0000FF00)>>8; 13 int blue = (col&0x000000FF); 14 int gray = (int)((float)red*0.3+(float)green*0.59+(float)blue*0.11); 15 int newColor = alpha|(gray<<16)|(gray<<8)|gray; 16 } 17 }