extend framebuf.blit method with parameters to select a rectangle from the source
I am trying to implement font rendering. I have loaded a single bitmap of all letters, and now I want to blit each letter to the destination. However, there is currently no framebuf method for blitting a partial framebuf.
Currently its blit(fbuf, x, y, [key])
I suggest blit(fbuf, x, y, [key], [sx,sy,sw,sh]) although I'm not clear on whether width & height are better than right and bottom.
It would bring major performance gains to do partial blitting in C over Python, and I don't want to allocate a tiny framebuf for every letter of the alphabet.
RFC extmod/modframebuf.c Support for blitting from 1-bit to n-bit colour maps
We now have 1-bit horizontal maps. One use for these is for rendering bitmaps such as font glyphs by blitting from a framebuf containing the glyph to the destination framebuf. This works - in a geometry agnostic manner - on monochrome displays where the destination uses 1-bit colour mapping.
Where the destination uses n-bit colour maps the resultant colour is unexpected. The general solution is to introduce the concept of palettes defining a mapping between differing colour spaces. This is not 'micro'.
A 'micro' solution might be to add an optional colour arg to the blit method which, when the source framebuf has a 1-bit mapping, causes the blit to be rendered in the supplied colour. This would enable fast font rendering in arbitrary colours and would be easily implemented.
Or is there a better approach?