我正在尝试开发一个可以对现有图像应用一些基本效果的应用程序。我对它很好。但是当我开始玩像素时,它就停止了工作。有人可以帮我解决吗?我应该使用另一个线程而不是主线程来编写以下代码吗?
int[] imagePixels = new int[picWidth * picHeight];
bitmap.getPixels(imagePixels, 0, picWidth, 0, 0, picWidth, picHeight);
for (int y = 0; y < picHeight; y++) {
for (int x = 0; x < picWidth; x++) {
int index = y * picWidth + x;
int red = (imagePixels[index] >> 16) & 0xff;
int green = (imagePixels[index] >> 8) & 0xff;
int blue = imagePixels[index] & 0xff;
red = (int) Math.abs(red-255);
green = (int) Math.abs(green-255);
blue = (int) Math.abs(blue-255);
imagePixles[index] = 0xff000000 | (red << 16) | (green << 8) | blue;
}
}
bitmap.setPixels(imagePixels, 0, picWidth, 0, 0, picWidth, picHeight);