[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

Exception thrown by Graphics.DrawImage

Robin Prosch via .NET 247

9/22/2004 4:39:00 AM

I have a program that displays a data plot from a Metafile object. The program gets a bunch of data, creates this Metafile object, and draws stuff to the Metafile. The Metafile is then drawn to a control using the Graphics.DrawImage method in the control's Paint event. Like this...

If Not MyMetafile is Nothing Then
e.Graphics.DrawImage(MyMetafile, ClientRectangle, ViewRectangle, GraphicsUnit.Pixel)
End If

The user can zoom and pan the data plot with mouse input. The MouseMove event of the control causes a repaint with the Invalidate method. The zooming and panning is accomplished by adjusting the ViewRectangle parameter in the snippet above.

This all works pretty well most of the time, but now and then - for no apparent reason that I can discover - this method call will throw an "Object reference not set to an instance" exception and kill the whole thing. This happens when panning or zooming, which is just a process of drawing the same Metafile with a different rectangle, so I don't know what's going on.

Does this situation ring a bell with anyone? Could there be something wrong with this Metafile that would cause this occasional error? Am I, perhaps, going about this in the totally wrong way?

--------------------------------
From: J Werner

-----------------------
Posted by a user from .NET 247 (http://www.dotn...)

<Id>uofEkYZvEUOS0LtvRVO8FA==</Id>