Hello!

I'm developing a Live Wallpaper and am currently looking into
optimizing the drawing part. I have a precalculated int[] of colors
and need to deliver this to the screen. The fastest way I have found
up to now is this:

  int[] pixels = new int[surfaceWidth * surfaceHeight];
  IntBuffer pixelBuffer = IntBuffer.wrap(pixels);
  bitmap = Bitmap.createBitmap(surfaceWidth, surfaceHeight,
Config.ARGB_8888);

  // when updates to "pixels" are done, I just blit it to the canvas
like this:
  canvas = getSurfaceHolder().lockCanvas();
  bitmap.copyPixelsFromBuffer(pixelBuffer);
  canvas.drawBitmap(mBitmap, 0, 0, null);
  holder.unlockCanvasAndPost(c);

The extra intermediate copying onto the bitmap seems redundant and I
was hoping to get rid of it. Canvas.drawBitmap(int[], ...) looks on
the surface to do the trick but is surprisingly a few ms slower.
Digging into the source code reveals that it also makes a complete
copy of the data onto a Bitmap before drawing. I have tried updating
the Bitmap directly but it has proven much slower due to the many
method calls needed.

Is there a faster way to get the int[] onto the surface?

Thanks,
apan

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to