我在我的项目为Android 2.3.3一个简单的图像,我想知道的第一个像素的颜色,并与颜色的背景颜色更换的每个像素....我什么都试过像迭代的像素和设置像素的颜色,我什么也没有......例如,与画面:
I have a simple image in my project for android 2.3.3 that i want to know the color of the first pixel and replace every pixel with that color to the background color.... I tried everything like iterating the pixels and setting the color of the pixels and I get nothing...For example,with that picture:
https://m.xsw88.com/allimgs/daicuo/20230907/6063.png.jpg
我想获得这样的结果是: https://www.dropbox.com /s/r9zox7zueekq2xe/img3.jpg
I want to get a result like that: https://m.xsw88.com/allimgs/daicuo/20230907/6064.png.jpg
我是为Android一个非常新的开发者,正因为如此对不起我的纳伊夫的问题!
I'm a very new developer for Android, and because of that sorry for my NAIF question!
只需使用ColorFilter实现这一目标。它将替换一种颜色与另一个。工作例如:
Simply use ColorFilter to achieve this. It will replace one colour with another. Working example:
Paint pnt = new Paint();
Bitmap myBit = BitmapFactory.decodeFile(pathName);
Canvas myCanvas = new Canvas(myBit );
int myColor = myBit.getPixel(0, 0);
// Set the colour to replace.
ColorFilter filter = new LightingColorFilter(myColor, Color.WHITE );
pnt.setColorFilter(filter);
// Draw onto new bitmap. result Bitmap is newBit
myCanvas.drawBitmap(myBit,0,0, pnt);