diff --git a/src/gui/mainwindow.py b/src/gui/mainwindow.py --- a/src/gui/mainwindow.py +++ b/src/gui/mainwindow.py @@ -33,15 +33,16 @@ class MainWindow(tk.Frame): w=int(self.imgView['width']) h=int(self.imgView['height']) - self.img=ImageTk.PhotoImage(frame.resize((w,h),resample=PIL.Image.BILINEAR)) - - wo,ho=self.currentFrame.size # o for original + wo,ho=frame.size # o for original widthRatio=wo/w heightRatio=ho/h self._imgSizeCoef=max(widthRatio,heightRatio) # shift compensates possible horizontal or vertical empty margins from unmatching aspect ratios self._imgShift=EPoint(wo-w*self._imgSizeCoef,ho-h*self._imgSizeCoef)/2 + frame.thumbnail((w,h)) # resize + self.img=ImageTk.PhotoImage(frame) + def _createWidgets(self): # a captured frame with overlay graphics self.imgView=tk.Canvas(self) @@ -69,6 +70,8 @@ class MainWindow(tk.Frame): ## Stores a grid corner located at x,y coordinates. def addCorner(self,x,y): self.corners.add(x,y) + log.debug("click on %d,%d",x,y) + log.debug("sizeCoef: %f, shift: %d,%d",self._imgSizeCoef,self._imgShift.x,self._imgShift.y) if self.corners.canonizeOrder(): # transform corners from show coordinates to real coordinates log.debug(self.corners.corners) @@ -81,7 +84,7 @@ class MainWindow(tk.Frame): ## Redraws the current image and its overlay. def redrawImgView(self): if self.currentFrame and self.img: - self.imgView.create_image(2,2,anchor="nw",image=self.img) + self.imgView.create_image(240,180,anchor="center",image=self.img) for corner in self.corners.corners: self.markPoint(corner.x,corner.y)