Example #1
0
 def test_lib_floatcanvas_fc_scaledbitmap2(self):
     fccanvas = fc.FloatCanvas(self.frame)
     
     bmp = wx.Bitmap(pngFile)
     obj = fc.ScaledBitmap2(bmp, (2, 2), 100)
     
     fccanvas.AddObject(obj)
Example #2
0
 def add_image(self, filename):
     print('Loading ' + filename)
     image = wx.Image(filename)
     img = FloatCanvas.ScaledBitmap2(image, (0, 0),
                                     Height=image.GetHeight(),
                                     Position='tl')
     self.Canvas.AddObject(img)
Example #3
0
    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)
        self.CreateStatusBar()

        # Add the Canvas
        Canvas = NavCanvas.NavCanvas(
            self,
            ProjectionFun=None,
            BackgroundColor="DARK SLATE BLUE",
        ).Canvas
        Canvas.MaxScale = 20  # sets the maximum zoom level
        self.Canvas = Canvas

        self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove)

        # create the image:
        image = wx.Image(ImageFile)
        self.width, self.height = image.GetSize()
        img = FloatCanvas.ScaledBitmap2(
            image,
            (0, 0),
            Height=image.GetHeight(),
            Position='tl',
        )
        Canvas.AddObject(img)

        self.Show()
        Canvas.ZoomToBB()
Example #4
0
    def load_image(self, filename):
        print('Loading ' + filename)

        wait = wx.BusyInfo("Loading overview image...")
        try:
            self._wximage = wx.Image(filename)
        finally:
            del wait

        if not self._wximage.IsOk():
            return

        img = FloatCanvas.ScaledBitmap2(self._wximage,
                                        (0, 0),
                                        Height=self._wximage.GetHeight(),
                                        Position='tl')
        # CHECKME: why use ScaledBitmap2 instead of ScaledBitmap? Performance? - our overview images are really large.

        # Note: we place the image such that the FloatCanvas origin (0,0) is in the top left corner ('tl') of the image,
        # because that is what ImageJ also does. Because we used ImageJ sometimes to experiment with image processing,
        # and since we sometimes export lineart data from ImageJ for use in Tomo, it makes sense to use the same convention.
        # The y-axis in ImageJ however points down, whereas by default in FloatCanvas it points up, so sometimes we will
        # need to flip the sign of the y-coordinates of our lineart objects when drawing them onto the FloatCanvas
        # on top of the image. (CHECKME: It would be nice if we could just use a coordinate transform to flip these
        # objects when drawing, we'll have to look into that...)

        if self._image != None:
            self._remove_image()

        # If we have lineart already, it needs to be on top of the image.
        # Since there apparently is no way to re-order the FloatCanvas objects (?!),
        # it seems we need to remove all lineart first,
        # then add the image, and finally recreate all lineart again.
        # TODO!

        self._image = self.Canvas.AddObject(img)