How to reverse the y-axis of the imported image in Tkinter?

后端 未结 3 1490
故里飘歌
故里飘歌 2021-01-18 04:46

For duplicate-markers: I am fully aware that there are some similar questions in matplotlib, such as this one. My question is about

3条回答
  •  迷失自我
    2021-01-18 05:08

    An angle can be used like such:

    image = Image.open("lena.jpg")
    angle = 180
    tkimage = ImageTk.PhotoImage(image.rotate(angle))
    ...
    

    It would be possible to draw the picture, and use reversed coordinates (so when you know the size of the canvas, instead of saying 50x50, you could use (max-50)x(max-50).

    The question is whether axes.imshow can handle the ImageTk.PhotoImage. Then again, I am not entirely sure if you'd just want this on a Tkinter canvas instead, e.g.:

    canvas_obj = self.canvas.create_image(250, 250, image=tkimage)
    

提交回复
热议问题