BIT-101 [2003-2017]

Lock your bitmaps!


Yesterday I posted about offscreen buffering techniques in bitmapdata drawing. And did some time tests that showed that doing a lot of drawing to an offscreen bitmap and then drawing that bitmap to your onscreen bitmap can save a significant amount of time. Guy Watson then came on and mentioned the lock() and unlock() methods of BitmapData, which, to be honest, I’d probably seen but wasn’t really aware of. Redoing the tests, locking each bitmap before drawing to it, and unlocking after drawing, showed that this brought all the tests down to the same level as the offscreen buffering example. Actual results and test code are on yesterday’s post. I just wanted to point this out in its own post in case people didn’t read all the comments. Calling lock()/unlock() is certainly a lot easier than creating a whole new bitmapdata, keeping track of it, and drawing back and forth. Thanks Guy.

« Previous Post
Next Post »