Added support for rendering of bitmaps and raw color images to display.TFT #205
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds two new methods to the
display.TFT
class to support direct rendering of bitmaps and raw 24-bit colour images. Use cases for the 1 bpp images include direct rendering of fonts created using font-to-py that are stored in ROM or displaying QR codes; 1 bpp images can be scaled, clipped and draw either solid or transparent. Direct rendering of 24 bpp images can be useful for displaying sensor data from array sensors (such as low-res thermal imagers) or allow faster display of more complex colour patterns.The method signatures for the two methods are:
and:
In both cases
x
andy
are the coordinates of the top,left corner of the image,width
andheight
are the dimensions of the image andbuffer
is an object that supports the memory buffer protocol (includingbytes
,bytearray
andmemoryview
objects, among others). In the case of therawImage()
method thebuffer
object should contain3*width*weight
bytes representing tuples of (r,g,b) bytes organised in lines proceeding left to right, the lines ordered top to bottom. For thedrawBitmap()
method thebuffer
object is made up of rows of bits, padded to a whole number of bytes, organised left to right, the lines ordered top to bottom. If thetopbitfirst
flag is set then the most significant bit of each byte is draw on the left and any padding is in the less significant bits, otherwise the least significant bit is draw on the left and padding is in the more significant bits. The bits that are set are draw in the color specified by thecolor
parameter if it is set or else the current foreground color. Bits that are zero are draw in the color given inbgcolor
if it is set or else the current background color, unless thetransparent
flag is set in which case they are not draw at all. If an integer is give for thescale
parameter then the image is scaled up by this value in both horizontal and vertical directions. If the value is a tuple of two items then these are taken as (x_scale, y_scale).