您好,我正在使用以下代码。它可以正确绘制小图像,但是我想绘制长图像,并且已被截断。似乎如果图像的宽度/高度大于35000像素,则表示像素不大于35000。我使用了bokeh库,但遇到了同样的问题。任何想法,可以添加到我的代码中的内容或任何解决方案都可以克服此限制:
from tkinter import *
from PIL import Image
from PIL import ImageTk
import tkinter.filedialog as fdialog
import cv2
class ScrolledCanvas(Frame):
def __init__(self, parent=None):
Frame.__init__(self, parent)
self.master.title("Spectrogram Viewer")
self.pack(expand=YES, fill=BOTH)
canv = Canvas(self, relief=SUNKEN)
canv.config(width=140, height=200)
canv.config(highlightthickness=0)
sbarV = Scrollbar(self, orient=VERTICAL)
sbarH = Scrollbar(self, orient=HORIZONTAL)
sbarV.config(command=canv.yview)
sbarH.config(command=canv.xview)
canv.config(yscrollcommand=sbarV.set)
canv.config(xscrollcommand=sbarH.set)
sbarV.pack(side=RIGHT, fill=Y)
sbarH.pack(side=BOTTOM, fill=X)
canv.pack(side=LEFT, expand=YES, fill=BOTH)
#self.im=Image.open("./1hr_original.jpg")
self.filename = fdialog.askopenfilename(filetypes=(("Image files", "*.jpg *.png"), ("All files", ".")))
self.im = Image.open(self.filename)
width,height=self.im.size
canv.config(scrollregion=(0,0,width,height))
self.im2=ImageTk.PhotoImage(self.im)
self.imgtag=canv.create_image(0,0,anchor="nw",image=self.im2)
ScrolledCanvas().mainloop()