I am trying to port the emulator that I wrote in java for android. Everything went well, I was able to transfer most of my codes with slight changes, however, due to the way the emulation works, I need to display the image at the pixel level.
As for java desktop I use
int[] pixelsA = ((DataBufferInt) src.getRaster().getDataBuffer()).getData();
which allow me to get a link to the pixel buffer and update it on the fly (minimize object creation)
This is currently what my android emulator does for each frame
@Override public void onDraw(Canvas canvas) { buffer = Bitmap.createBitmap(pixelsA, 256, 192, Bitmap.Config.RGB_565); canvas.drawBitmap(buffer, 0, 0, null); }
pixelsA is an int [] array, pixelsA contains all the color information, so each frame will have to create a raster object by doing
buffer = Bitmap.createBitmap(pixelsA, 256, 192, Bitmap.Config.RGB_565);
which I find quite expensive and slow.
Is it possible to draw pixels efficiently with a canvas?
android image pixel android-canvas draw
afro100
source share