Improving getpixel () and setpixel () speed on Android Bitmap

All,

After I noticed how slow getPixeland setPixel(not sure which one, guess they both have no turbo boost), I quickly encoded a container for Bitmapthat uses an array int[]to process bitmap operations.

Already - it is noticeably faster, but this is not enough. Please, could you advise how to speed it up?

My idea is to keep track of what the "dirty" functions have done setPixeland update only this part Bitmapwhen called getBitmap()... it is not clear how to set the setPixelsparameters (something with an offset and a step, I think).

Also - any faster recipe?

Thanks for the help!

import android.graphics.Bitmap;

public class DrawableBitmapContainer {
private Bitmap image;
private int width, height;
private int[]  pixels;
public DrawableBitmapContainer(Bitmap _source ){
    image = _source;
    width = image.getWidth();
    height = image.getHeight();
    pixels = new int[width*height];
    image.getPixels(pixels,0,width,0,0,width,height);
}
public int getPixel(int x,int y){
    return pixels[x+y*width];
}
public void setPixel(int x,int y, int color){
    pixels[x+y*width]=color;
}
public Bitmap getBimap(){
    image.setPixels(pixels,0,width,0,0,width,height);
    return image;
}
public int getWidth(){
    return image.getWidth();
}
public int getHeight(){
    return image.getHeight();
}
}
+5
2

, setPixel/getPixel, .

pixels , . , , pixels , , , , .

. Android.

, ++, NDK.

+4

- android ndk. , , .

0

All Articles