这里引用https://stackoverflow.com/a/8737690/5220210 我正在尝试处理位图上的每个像素,所以我有这个
int [] pixel = {0x0, 0x0, 0x0};
int [] pixels_old, pixels_new;
int [] params = {image_source.getWidth(), image_source.getHeight()};
int [] image_params = {image_source.getWidth() - 2 * anaglyph_amplitude, image_source.getHeight()};
pixels_old = new int[params[2] * params[3]];
pixels_new = new int[image_params[0] * image_params[1]];
image_source.getPixels(pixels_old, 0, params[2], 0, 0, params[2], params[3]);
image_source = null;
for(int i = 0; i < image_params[0]; ++i)
for(int j = 0; j < image_params[1]; ++j) {
pixel[0] = pixels_old[i + j * params[2]];
pixel[1] = pixels_old[i + (anaglyph_amplitude<<1) + j * params[2]];
pixel[2] = pixel[0] + (pixel[1] & 0xFFFF) - (pixel[0] & 0xFFFF);
pixels_new[i + j * image_params[0]] = pixel[2];
}
pixels_old = null;
image_source = Bitmap.createBitmap(pixels_new, image_params[0], image_params[1], Bitmap.Config.ARGB_8888);
pixels_new = null;
但我不知道什么是anaglyph_amplitude。请知道,请帮助我。我已经研究过但无法找到意义。感谢