【发布时间】:2014-05-28 05:24:11
【问题描述】:
我在我的 Android 应用程序 中使用此代码将位图转换为纯黑白并且它可以工作:
public Bitmap ConvertToThreshold(Bitmap anythingBmap)
{
int width = anythingBmap.getWidth();
int height = anythingBmap.getHeight();
int threshold = 120;
for(int x=0;x<width;x++){
for(int y=0;y<height;y++){
int pixel = anythingBmap.getPixel(x, y);
int gray = Color.red(pixel);
if(gray < threshold){
anythingBmap.setPixel(x, y, 0xFF000000);
} else{
anythingBmap.setPixel(x, y, 0xFFFFFFFF);
}
}
}
return anythingBmap;
}
.getPixel() 非常慢的问题,因此这需要很长时间来处理。有更快的方法吗?
谢谢
【问题讨论】: