Skip to content

Can only draw full screen image #48

Closed
@Johennes

Description

@Johennes

The image method currently only allows to redraw the whole screen.

    def image(self, img, rotation=None):
        ...
        imwidth, imheight = img.size
        if imwidth != self.width or imheight != self.height:
            raise ValueError(...
        ...
        self._block(0, 0, self.width-1, self.height - 1, pixels)

Especially on lower end boards it seems advantageous to be able to draw smaller images in part of the screen only without having to refresh the whole screen.

I would like to suggest to add two new arguments to the method for specifying the origin

    def draw(self, image, x0=0, y0=0):

to drop the if imwidth != self.width or imheight != self.height: check and to adapt the call to _block so that the image's size is passed in instead of the screen size.

    self.display._block(x0, y0, x0 + imwidth - 1, y0 + imheight - 1, pixels)

Instead of removing the size check, one could also replace it with a check to ensure that the image is not bigger than the screen size.

Happy to submit a pull request if this makes sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions