Skip to content

Request for slice capability for bitmap manipulation #3004

@kmatch98

Description

@kmatch98

This is a request for capability for slice manipulation for bitmaps. This would allow more of the code to be performed "down" at the C-level rather than item-by-item manipulation up at the CircuitPython level.

Use case description: For developing an updated text display capability to reduce memory usage vs. label when using imported BDF files, one way is to create a bitmap buffer to contain the text, rather than a group of tileGrids. To do this, I copy each glyph bitmap into the display bitmap buffer. This is currently implemented in this textMap library. Currently I iterate across the x and y of the small glyph bitmap and copy it into a larger Target bitmap at the Target x,y location.

A superior approach could be a method where I pass a source bitmap with slice notation (if I want to copy only a portion of the source bitmap) and then a Target bitmap and Target x,y location. If this copying can happen more down at the C-level it would likely be faster compared to the element by element copying approach.

Additional background: This issue suggests that direct index manipulation of arrays array[3] can be superior to x,y tuple array[0,3] manipulation of arrays #2688. I updated my textMap library to use direct indexing and got a 20% reduction in time (the test includes rendering plus a lot of other parsing work, so the bitmap writing speed improvement alone was actually improved more than 20%).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions