c++ - Resizing a double buffered widget? -


Right now, my text widget is double buffered (when an event occurs when it draws text to a bitmap)

When I change the size of the widget, it does a great job. When I change its shape, I create a new with al_destoy_bitmap and new dimensions. It is very slow. How do most Double Buffed Guis like Windows and Mac OSX avoid this problem?

Thanks

I recently double buffering for the purpose of collision detection Flash is There was a similar problem, bitmap data structures were relatively slow (it is very sad in itself because allotment of raw memory should be flash and your case is fast).

What I did was to just support the bitmap to cache and reuse it whenever possible, so if someone would change the size of 250x250 then I could use a bitmap again 280x260 was. Whenever a widget was done with a bitmap, it will be reused to use it again, or if they shrink and can use a small one I had a cap on the total memory used It could be done and if unused bitmap is crossed then it will tamper it.

But you do not have to be so extreme that for a simple first step, you change shape in large increments. For example, even if the user has changed the shape in just 2 pixels size, you can resize the internal bitmap by 50. In this way, you can use bitmaps as long as the users do not hit the new size limit.

If the user decreases the size, then you do not need to do anything, because your current bitmap is large enough to do the drawing. When you copy it to the screen, just copy its upper-left corner (the part you actually use).

Comments