网上随便找了个二维码扫描工具,可是无论怎么回事都扫不出来有些图片,PM建议我把图片偏白的地方改成纯白,偏黑的地方改成纯黑,于是方法如下:
private Bitmap makeBitmapBlackWhite(Bitmap baseBitmap) {
int width = baseBitmap.getWidth();
int height = baseBitmap.getHeight();
int color, r, g, b, a;
int[] oldPixels = new int[width * height];
int[] newPixels = new int[width * height];
Bitmap myCopyBitmap = Bitmap.createBitmap(baseBitmap.getWidth(), baseBitmap.getHeight(), baseBitmap.getConfig());
baseBitmap2.getPixels(oldPixels, 0, width, 0, 0, width, height);
//然后就去遍历这个数组oldPixels,并取出每个像素,然后再取出每个像素的ARGB属性,然后通过想修改ARGB属性,得到新的像素点
//并把新的像素点保存新的数组newPixels中
for (int i = 0; i < width * height; i++) {
color = oldPixels[i];//取出每一个像素点
if (color<0xffaaaaaa){
color=0xff000000;
}else{color=0xfff