Error at Form Level when resizing PictureBox

T

Tony Lugg

I have a UserControl with AutoScroll and a PictureBox that I load
images into. The PictureBox is set to stretch the image, and in order
to achieve a zoom effect, the PictureBox is made bigger (or smaller if
zooming out). This works fine, except that with a large image I
eventually get an exception. NOTE: I was using DrawImage initially
but performance was poor.

However, the exception is not being generated at the line where the
PictureBox is enlarged...the system seems to syspend for a few
seconds, then an error is generated stating:

<<An unhandled exception of type
'System.ComponentModel.Win32Exception' occurred in
system.windows.forms.dll

Additional information: The operation completed successfully>>

Thanks for that additional information!

I cannot seem to trap this error as it is happening at the very first
line of the form definition "Public Class MyForm". Obviously, this
would generate a run-time issue for my application. I have 2
questions:

1. What are the size limits for a PictureBox?
2. How can I trap an error that seems to occur at the form level.

Thanks in advance.
 
R

Robin Tucker

As this is a win32 error, I suggest the image size is probably dependant on
your graphics hardware and the error is related to this. Besides, this is
not the right way to go about things at all. What you need to do is render
the image onto the surface using a "source" and "destination" image
rectangle. The source image will be the zoom area and the destination
rectangle, your image surface.
 
T

Tony Lugg

Thanks Robin.

I thought it was a hardware limit. I did mention that I was using
DrawImage initially to accomplish exactly what you were saying with the
source and destination rectangles. However, (and there are other
threads on this) the performance of DrawImage was unacceptable.
Apparently, the next version of GDI+ will have better performance, but I
can't live with what it has currently.

If this has not been your experience when dealing with large images,
then please provide me with some sample code.

Thanks for your reply
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top