//改变图片三色值,频繁调用方法,不要用静态,静态生命周期太长,不容易销毁
public Bitmap drawBg4Bitmap(int progress,int progressR,int progressG,int progressB, Bitmap orginBitmap, int id,boolean isSuCai) {
int w = orginBitmap.getWidth();
int h = orginBitmap.getHeight();
int bytes = orginBitmap.getByteCount();
ByteBuffer buf = ByteBuffer.allocate(bytes);
orginBitmap.copyPixelsToBuffer(buf);
byte[] byteArray = buf.array();
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
int index = y * w + x;
int A = convertByteToInt(byteArray[index * 4 + 3]);
if (A > 10) {
if(isSuCai){
if (isPureColor ==1) {
byteArray[index * 4] = (byte) progressR;
byteArray[index * 4 + 1] = (byte) progressG;
byteArray[index * 4 + 2] = (byte) progressB;
} else {
switch (id) {
case 0:
byteArray[index * 4] = (byte) progress;
break;
case 1:
byteArray[index * 4 + 1] = (byte) progress;
break;
case 2:
byteArray[index * 4 + 2] = (byte) progress;
break;
default:
break;
}
}
}else {
switch (id) {
case 0:
byteArray[index * 4] = (byte) progress;
break;
case 1:
byteArray[index * 4 + 1] = (byte) progress;
break;
case 2:
byteArray[index * 4 + 2] = (byte) progress;
break;
default:
break;
}
}
}
}
}
Bitmap stitchBmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
stitchBmp.copyPixelsFromBuffer(ByteBuffer.wrap(byteArray));
return stitchBmp;
}