Skip to content

Can only draw full screen image #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Johennes opened this issue Nov 15, 2019 · 1 comment · Fixed by #50
Closed

Can only draw full screen image #48

Johennes opened this issue Nov 15, 2019 · 1 comment · Fixed by #50

Comments

@Johennes
Copy link
Contributor

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.

@ladyada
Copy link
Member

ladyada commented Nov 17, 2019

yep please submit a PR to image(), you can add extra kwargs for x, y.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants