Skip to content Skip to sidebar Skip to footer

Bitmapdata Lock And Unlock Not Working On Android

The following code will erase a bitmap (brush akk droplet) from another bitmap (akka The code works great on PC and pretty ok performacewise. When i test it on more android devi

Solution 1:

For your original question, sometimes GPU mode doesn't pick up changes into the underlying bitmapdata. Try any one of these operations after your unlock() to 'hint' that it should re-upload the bitmap data:

bm.filters = [];bm.bitmapData = m;bm.alpha = 0.98+Math.random()*0.02;

But as you found, uploading bitmapdata can be slow. To clarify GPU/direct render modes:

In GPU mode, changing any pixel in a Bitmap requires a re-upload of the full bitmap, so it's the size of Bitmap that's the limiting factor. In direct mode, it blits only the portions of the screen that have been updated. So I'd guess some parts of the game change a lot of the screen at once (slow in direct mode), whereas this effect changes a large bitmap, but only a little bit at a time (slow in GPU mode).

You have to get creative to maximize your performance wrt GPUs:

  1. In GPU mode, split the effect into many bitmaps, and only change as few as possible for any given frame. (medium effort)
  2. Use Starling GPU-accelerated framework and Starling filters (GPU shaders) to achieve your effect (effort depends on how much you have invested in your game already), see a couple of examples

Post a Comment for "Bitmapdata Lock And Unlock Not Working On Android"