4 ms·
I used the Command pattern in LibreOffice to create a “filter” for animations and bitmaps. I created a BitmapFilter class [1] it just has an execute abstract f
by chris_wot 4y ago
I used the Command pattern in LibreOffice to create a “filter” for animations and bitmaps.
I created a BitmapFilter class [1] it just has an execute abstract function which you override to create your own objects.
For convenience I created a static Filter function that takes a command object and then executes it to return a bitmap.
It means I never have to modify the Bitmap or BitmapEx classes to implement functions that modify the bitmap. Just derive from BitmapFilter’s class and you are up and running!
1. https://opengrok.libreoffice.org/xref/core/include/vcl/BitmapFilter.hxx?r=3aef606f https://opengrok.libreoffice.org/xref/core/include/vcl/Bitma...
- ajuc 4y agoThis is the standard way to implement Undo in editors. You have operations that are put onto stack and applied one after another on the original data. You can cache intermediate results for optimization. And when you undo - you just pop the last operation from the stack.