mindsensorsUI.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:PiStorms 作者: mindsensors 项目源码 文件源码
def fillBmp(self, x, y, width, height, path = "/usr/local/mindsensors/images/Pane1.png", display = True):
        buff = self.disp.buffer
        actx = self.screenXFromImageCoords(x,y)
        acty = self.screenYFromImageCoords(x,y)
        # if the caller only provided icon name, assume it is in our system repository
        if (path[0] != "/"):
            path = "/usr/local/mindsensors/images/" + path

        # if the image is missing, use a default X image.
        if (os.path.isfile(path)):
            image = Image.open(path)
        else:
            image = Image.open("/usr/local/mindsensors/images/missing.png")

        image = image.resize((width,height), Image.ANTIALIAS)

        cr = self.currentRotation
        if(cr == 1):
            actx -= height
            image = image.transpose(Image.ROTATE_270)
        if(cr == 2):
            acty -= height
            actx -= width
            image = image.transpose(Image.ROTATE_180)
        if(cr == 3):
            acty -= width
            image = image.transpose(Image.ROTATE_90)

        buff.paste(image, (actx,acty))
        if(display):
            self.disp.display()

    ## Draw a  image on the screen using supplied image data
    #  @param self The object pointer.
    #  @param x The upper left x coordinate of the image.
    #  @param y The upper left y coordinate of the image.
    #  @param width The width of the image.
    #  @param height The width of the image.
    #  @param image data
    #  @param display Choose to immediately push the drawing to the screen. Optional, defaults to True.
    #  @remark
    #  To use this function in your program:
    #  @code
    #  ...
    #  screen.screen.fillBmp(40, 0, 240, 240, image)
    #  @endcode
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号