Bill Burns wrote:
> I've been trying out Floatcanvas for a day or so and I've hit a little snag.
> I'm probably trying to do something that Floatcanvas wasn't designed to do ;)
not exactly, but it should work...
> I'm getting PyAssertionError from wx.core and I'm wondering if the TIF files
> I'm working with are just too large?
probably, but I think it's FC's fault.
> I can make the TIF an array using PIL & numpy, but I'm not sure how to add an
> array to the Canvas (and I don't know if that would help anyway?)
nope -- internally FC needs a wxImage anyway. It's pretty easy to make a
wx.Image form a numpy array, but loading it into a wx.Image for a tiff
file is the easiest way to go.
> Since I couldn't figure out the array thing, I'm just converting it with
> wx.Bitmap() and using the AddScaledBitmap() method...
Here's the trick. When I first wrote ScaledBitmap, I was imaginig using
it for small bitmaps, like icons, etc. So it's not at all smart -- when
you zoom, it sclaes the entire image, then draws it, even though on ly a
prortion may be visible.
I"ve written a ScaledBitmap2, which does "the right thing", and only
scales the portion of the image you need. It may be buggy if you orient
it any way other than 'tl', or do anythign with a projection function,
but give it a try:
SBM = FloatCanvas.ScaledBitmap2(MyBitmapOrImage, (x,y), ...)
Canvas.AddObject(SBM)
and see how that works for you.
> I'm including a "testing" TIF that will make the exception(s) occur. It isn't
> much to look at... but it has the exact same size, pixels, dimensions,
> resolution, bit depth & compression used in my "normal" TIF's.
>
> Here's my specs:
> ----------------
> 32-bit Windows Vista Home Premium SP2 with 3.0GB Ram
> Python 2.6
> wxPython 2.8-msw-unicode
> The latest FloatCanvas from svn
>
> I'd appreciate any help or pointers! Thanks!
>
> Bill
> """
>
> import wx
> from wx.lib.floatcanvas import NavCanvas
>
> class MyFrame(wx.Frame):
> def __init__(self, *args, **kwargs):
> wx.Frame.__init__(self, *args, **kwargs)
>
> self.CreateStatusBar()
>
> NV = NavCanvas.NavCanvas(self, -1, Debug=0, BackgroundColor="GREY")
> self.Canvas = NV.Canvas
>
> bmp = wx.Bitmap("Test.tif", wx.BITMAP_TYPE_TIF)
>
> self.Canvas.AddScaledBitmap(bmp, (0, 0), 1, Position="cc")
>
> self.SetPosition((0, 0))
> self.Show()
> self.Canvas.ZoomToBB()
>
> if __name__ == "__main__":
> app = wx.App(False)
> frame = MyFrame(None, title="Float Canvas Tester", size=(1680, 1020))
> app.MainLoop()
>
> #~ This is the traceback I hit most often:
> """
> Traceback (most recent call last):
> File
> "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\floatcanvas\FloatCanvas.py",
> line 2644, in LeftUpEvent
> self.GUIMode.OnLeftUp(event)
> File
> "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\floatcanvas\GUIMode.py",
> line 309, in OnLeftUp
> self.Canvas.ZoomToBB( BBox.fromPoints(N.r_[EndRBBox,StartRBBox]) )
> File
> "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\floatcanvas\FloatCanvas.py",
> line 2947, in ZoomToBB
> self.SetToNewScale(DrawFlag=DrawFlag)
> File
> "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\floatcanvas\FloatCanvas.py",
> line 2960, in SetToNewScale
> self.Draw()
> File
> "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\floatcanvas\FloatCanvas.py",
> line 2793, in Draw
> self._DrawObjects(dc, self._DrawList, ScreenDC, self.ViewPortBB, HTdc)
> File
> "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\floatcanvas\FloatCanvas.py",
> line 3098, in _DrawObjects
> Object._Draw(dc, WorldToPixel, ScaleWorldToPixel, HTdc)
> File
> "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\floatcanvas\FloatCanvas.py",
> line 1915, in _Draw
> Img = self.Image.Scale(W, H)
> File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py",
> line 2687, in Scale
> return _core_.Image_Scale(*args, **kwargs)
> wx._core.PyAssertionError: C++ assertion "data" failed at
> ..\..\src\common\image.cpp(462) in wxImage::Scale(): unable to create
> image
> """
>
> #~ I hit this one occasionally:
> """
> Traceback (most recent call last):
> File
> "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\floatcanvas\FloatCanvas.py",
> line 2644, in LeftUpEvent
> self.GUIMode.OnLeftUp(event)
> File
> "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\floatcanvas\GUIMode.py",
> line 309, in OnLeftUp
> self.Canvas.ZoomToBB( BBox.fromPoints(N.r_[EndRBBox,StartRBBox]) )
> File
> "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\floatcanvas\FloatCanvas.py",
> line 2947, in ZoomToBB
> self.SetToNewScale(DrawFlag=DrawFlag)
> File
> "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\floatcanvas\FloatCanvas.py",
> line 2960, in SetToNewScale
> self.Draw()
> File
> "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\floatcanvas\FloatCanvas.py",
> line 2793, in Draw
> self._DrawObjects(dc, self._DrawList, ScreenDC, self.ViewPortBB, HTdc)
> File
> "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\floatcanvas\FloatCanvas.py",
> line 3098, in _DrawObjects
> Object._Draw(dc, WorldToPixel, ScaleWorldToPixel, HTdc)
> File
> "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\lib\floatcanvas\FloatCanvas.py",
> line 1919, in _Draw
> dc.DrawBitmapPoint(self.ScaledBitmap, XY, True)
> File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_gdi.py",
> line 3471, in DrawBitmapPoint
> return _gdi_.DC_DrawBitmapPoint(*args, **kwargs)
> wx._core.PyAssertionError: C++ assertion "bmp.Ok()" failed at
> ..\..\src\msw\dc.cpp(1181) in wxDC::DoDrawBitmap(): invalid bitmap in
> wxDC::DrawBitmap
> """
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> FloatCanvas mailing list
> [email protected]
> http://paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
_______________________________________________
FloatCanvas mailing list
[email protected]
http://paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas