I have the image_source
that is the source bitmap with some picture and image_new
— temporary bitmap
I do this code, that makes image_source
be anaglyph background layer:
int [] pixel = {0x0, 0x0, 0x0};
int [] image_params = {image_source.getWidth() - 2 * anaglyph_amplitude, image_source.getHeight()};
Bitmap image_new = Bitmap.createScaledBitmap(image_source, image_params[0], image_params[1], false);
for(int i = 0; i < image_params[0]; ++i)
for(int j = 0; j < image_params[1]; ++j) {
pixel[0] = image_source.getPixel(i, j);
pixel[1] = image_source.getPixel(i + 2 * anaglyph_amplitude, j);
pixel[2] = pixel[0] + pixel[1] % 0x10000 - pixel[0] % 0x10000;
image_new.setPixel(i, j, pixel[2]);
}
image_source = Bitmap.createBitmap(image_new);
image_new = null;
Then image_source
is drawn to canvas (drawing to canvas at ones is not available).
The problem is that this programm takes about 5 seconds to process image with 1000x1000 size on smart Android device.
Are there any other ways to run bitmap pixels?