On Mon, Feb 3, 2014 at 1:15 PM, Nouvelle Collection <
[email protected]> wrote:

> self.Canvas.AddScaledBitmap(image, (0,0), Height=image.GetHeight(),
> Position = 'tl')
>
>
hmm -- this will create a ScaledBitmap with "world" height of 100 pixels.



> When I use a PNG of size (x,y) with x <= 100 or y <=100, I have a crash
> with the following traceback when I do ZoomToBB()   :
>
> Traceback (most recent call last):
>>>>   File "D:\Documents\test.py", line 471, in Draw
>>>>     self.Canvas.ZoomToBB()
>>>>   File "D:\Documents\floatcanvas\FloatCanvas.py", line 3035, in ZoomToBB
>>>>     self.SetToNewScale(DrawFlag=DrawFlag)
>>>>   File "D:\Documents\floatcanvas\FloatCanvas.py", line 3048, in
>>>> SetToNewScale
>>>>     self.Draw()
>>>>   File "D:\Documents\floatcanvas\FloatCanvas.py", line 2846, in Draw
>>>>     self._DrawObjects(dc, self._DrawList, ScreenDC, self.ViewPortBB,
>>>> HTdc)
>>>>   File "D:\Documents\floatcanvas\FloatCanvas.py", line 3186, in
>>>> _DrawObjects
>>>>     Object._Draw(dc, WorldToPixel, ScaleWorldToPixel, HTdc)
>>>>   File "D:\Documents\floatcanvas\FloatCanvas.py", line 1968, in _Draw
>>>>     Img = self.Image.Scale(W, H)
>>>>   File
>>>> "C:\ProgramData\Anaconda\lib\site-packages\wx-3.0-msw\wx\_core.py", line
>>>> 2916, in Scale
>>>>     return _core_.Image_Scale(*args, **kwargs)
>>>> wx._core.PyAssertionError: C++ assertion "(width > 0) && (height > 0)"
>>>> failed at ..\..\src\common\image.cpp(433) in wxImage::Scale(): invalid new
>>>> image size
>>>>
>>>
> Do you have any idea for the reason of this error ?
>

One idea  -- what else is on the canvas -- if everything else if big enough
(or far enough away) so that zooming to the bounding box would make the
ScaledBitmap less than 1 pixel in size, then it may be trying to scale to a
0-pixel image, which would trigger this. But I"m surprised that I didn't
already have a check for that.

That should be near here:

  File "D:\Documents\floatcanvas\FloatCanvas.py", line 1968, in _Draw
    Img = self.Image.Scale(W, H)

look and see if there is check for size-zero for W or H  -- if not then
there should be, and it can just skip the rest of the _draw method
-- nothing to draw.



> Note : if I resize (with MSPaint for example) the PNG to 101x101 pixels,
> there is no error anymore..
>

Also,  it seems odd that it would happen at exactly 100 pixels -- quite  a
round number.

If you post a small sample that breaks and the png that breaks it -- I'll
take a look.

-Chris





-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[email protected]
_______________________________________________
FloatCanvas mailing list
[email protected]
http://mailman.paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas

Reply via email to