0
我想將整個位圖設置爲灰度,但我想保留一種顏色,紅色或藍色或綠色或用戶喜歡的任何顏色? 這是可能的與colormatrix? 這是一個鏈接,這就是我想要做的,但在android中。 How can I convert an RGB image to grayscale but keep one color?Android將位圖轉換爲灰度,但保留一種顏色
非常感謝。
我想將整個位圖設置爲灰度,但我想保留一種顏色,紅色或藍色或綠色或用戶喜歡的任何顏色? 這是可能的與colormatrix? 這是一個鏈接,這就是我想要做的,但在android中。 How can I convert an RGB image to grayscale but keep one color?Android將位圖轉換爲灰度,但保留一種顏色
非常感謝。
試試這個:
ImageView imageView;
Bitmap photo,photo1;
photo1 = Bitmap.createBitmap(photo.getWidth(),photo.getHeight(),photo.getConfig());
for(int i=0;i<photo.getWidth();i++)
{
for(int j=0;j<photo.getHeight();j++){
int p=photo.getPixel(i,j);
int r= Color.red(p);
int g=Color.green(p);
int b=Color.blue(p);
int alpha=Color.alpha(p);
r=0;
g=g+150;
b=0;
alpha=0;
photo1.setPixel(i,j, Color.argb(Color.alpha(p),r,g,b));
}
}
imageView.setImageBitmap(photo1)
你應該給你的答案添加一些敘述。只有代碼的答案將被刪除。 – rghome
很好的挑戰,實際上!看看這裏和相關的文檔實現︰http://stackoverflow.com/a/6488289/2545832 –
我試過了,但它只是讓我的位圖更明亮。有沒有其他方法可以做到這一點? – RoterBaron