private void setCutBitmap(Bitmap resultBitmap) { for (int i = 0; i < resultBitmap.getWidth(); i++) { for (int j = 0; j < resultBitmap.getHeight(); j++) { int pixel = resultBitmap.getPixel(i, j); int alpha = Color.alpha(pixel); int red = (pixel & 0xff0000) >> 16; // 取高两位 int green = (pixel & 0xff00) >> 8;// 取中两位 int blue = (pixel & 0xff); // 取di if (alpha != 0) { if (maxX < i) { maxX = i; } if (minX > i) { System.out.println("minX=" + minX); minX = i; } if (maxY < j) { maxY = j; } if (minY > j) { minY = j; } } else { // System.out.println("red="+red+"green"+green+"blue"+blue); } } }
图片的裁剪函数用
Bitmap.createBitmap(resultBitmap, minX, minY, lengthX, lengthY);