adafruit / Adafruit-GFX-Library

Adafruit GFX graphics core Arduino library, this is the 'core' class that all our other graphics libraries derive from
https://learn.adafruit.com/adafruit-gfx-graphics-library
Other
2.41k stars 1.55k forks source link

add arbitrary rect drawing from bitmaps/canvases (RGB 565, RAM only) #442

Open aremmell opened 11 months ago

aremmell commented 11 months ago

For the project I am working on (a compositing window manager which uses Adafruit GFX/Arduino GFX Library as its underlying graphics driver layer), I have the need to draw only certain parts of a memory buffer/canvas containing the pixels to render to the display hardware (using the optimized hardware class' drawing routines).

As far as I can tell, there is currently no way to do that cleanly: I can only do an un-optimized loop and draw individual pixels, or call Adafruit_SPITFT's setAddrWindow and writePixels, but those are not part of the Adafruit_GFX interface (I may just change my underlying requirement to the SPITFT class instead of the GFX interface if this PR is unwanted).

In order to resolve this situation, I:

Limitations

I tested to make sure that the existing interface works as expected when calling with 0,0 for x,y and the bitmap's width and height, but I did not test edge cases like negative x,y or invalid width/height values. I did the best I could to mimic the logic that was already in place.

If more formal testing and proof that I didn't break anything is required, let me know and I will write something up.