Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Image Zooming Crashes Windows.Forms.dll?

2 views
Skip to first unread message

robert smith

unread,
Dec 26, 2002, 4:52:33 AM12/26/02
to
I've made a custom control to get rid of LeadTools, it does displays,
autoscrolling, crops, zooms and all the rest.

There is one thing that is very strange however, I've found that if I zoom
in a lot (beyond a users' normal needed amount) I get an untrappable
exception from the Forms dll.

Originally it seemed that just keeping the helper picturebox below 20k
pixels width or 20k pixels height woud solve thed problem, but more testing
killed that idea.

Currently I'm using the hopeful trap of keeping the width and/or height
below 10x the VirtualScreen dimensions. That seems to work in my test
scenarios so far ... but I don't know if it's really just luck. (since the
actual limits seem to vary by image type and resolution)

Has anyone else seen this untrappable error?

If you have a second, you can jump directly to the details in the
documentation page:

http://www.doitin.net/svICdemo4.htm#untrappable

Please posts ideas to this group.

Thanks for your time.

Robert Smith
Kirkland, WA


Frank Hileman

unread,
Dec 26, 2002, 9:52:34 AM12/26/02
to
Since you are doing so much work, did you ever think of abandoning the
picturebox completely? Just an idea, since the bug may be there.

"robert smith" <smithgetri...@smithvoice.com> wrote in message
news:Oai$KOMrCHA.2256@TK2MSFTNGP12...

robert smith

unread,
Dec 26, 2002, 12:16:25 PM12/26/02
to
The work is already done, it's harder to document it it than do it.

But even still: No. The code I've seen to work scrollbars off of images
without a picturebox display has been, in my humblest opinion, way too
flash-prone. Lots of lines of code, very impressive code, but so far as I
have seen, not providing as good and experience for the end user.

With the picturebox you get all the sizing - except for the Forms.dll issue
which is not a real major issue - with no flashing, jus smooth movemens.

Do you know of a better route that will actually work better,. no flashing,
no choppy displays?

Thanks, Frank.

-s

"Frank Hileman" <fran...@no.spamming.prodigesoftware.com> wrote in message
news:uh9qm5OrCHA.2396@TK2MSFTNGP10...

james

unread,
Dec 26, 2002, 1:16:15 PM12/26/02
to
Robert, on Microsofts's Visual Basic.NET website there is an 101
Examples.exe download
that has several good examples of working with GDI+ and includes one sample
of zooming and cropping that you might be interested in. I used parts of it
in a simple image program that I have been playing around with.
But, it too will cause the exception that you have experienced if you
enlarge an image too much. I think it has something to do with
Interpolation Mode. If you use High Quality
it seems to me that GDI+ uses Anti-Aliasing to smooth the resulting image
and that is where the problem occurs. Mainly because as the image grows
Anti-Aliasing seems (to me anyway) to loose too much pixel data to work
correctly with, resulting in the execption.
In my test program , I just set a maximum size that an image can be enlarged
or reduced to.
For me, that takes care of the problem.
I am just starting on actual editing of images in my test program. I would
like to be able to edit images (remove red eye, etc.) and save the results
to a new image. I have several ideas on how to do that.
Also, I just recently got a very informative book:"GDI+ Programming in C#
and VB.NET"
by: Nick Symmonds, published by: Apress books.
It really does have some good information in it. You might want to check it
out too.
james

"robert smith" <smithgetri...@smithvoice.com> wrote in message

news:uga$KGQrCHA.1644@TK2MSFTNGP09...

Frank Hileman

unread,
Dec 26, 2002, 5:29:05 PM12/26/02
to
Hello Robert,

Well, it is easy to get rid of flashing. Choppy would be a performance
problem. GDI+ has a couple calls that will display part of an image, crop
it, and scale it, all at the same time. So it does not look like "lots of
lines of code". You still need scroll bars. UserControl can do that.

Your problem may be from creating a giant image and running out of memory or
overflowing a coordinate (not in your code, but the MS code). Using the
DrawImage(Image, Point[], Rectangle, GraphicsUnit) call you can scale, crop,
and pan, all without creating a new image. I don't know how fast it is.
Because it does not create a new image, it probably will not have that
blowup problem, but it may be slower to pan, because it has to interpolate
on every repaint (interpolation quality can also affect speed). I worked on
a graphics system where the user had to pick between infinite zoom or fast
pan -- we had the same trade-off. If we cached the zoomed image, it could
take a long time to zoom in, and they might run out of memory. If we did
not, zooming was fast, no limits to zooming, but panning was slower.

Here is the DrawImage link:
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdrawinggraphic
sclassdrawimagetopic9.asp

To get rid of flashing you double buffer. Here is an article. And the next
link is a presentation and sample about GDI+ performance.
http://www.gotdotnet.com/team/windowsforms/windowsformspainting.aspx

http://windowsforms.net/samples/DEV354.zip

I imagine a custom control made this way would be as fast or faster than the
picturebox.

By the way, I enjoyed your articles, even though I am a C# developer.

Regards,
Frank Hileman

"robert smith" <smithgetri...@smithvoice.com> wrote in message

news:uga$KGQrCHA.1644@TK2MSFTNGP09...

robert smith

unread,
Dec 26, 2002, 10:07:50 PM12/26/02
to
Much abliged Frank.

I'm using DrawImage for the fixing of Tifs (fax compression commonly sets
the Y resolution to half of the X, I restore al images by a clone then a new
birtmap then a blast of the original using DrawImage.

No offense against C# at all, though I am a tad tired of seeing C++ folks
say that in C# the world has something so totally brand new, only to find
that much of what they're excited about is old to VB :) (No, no ...not
trying to start that old thing again <G>)

The next part I just have to write, it's how to draw templates that later
are filled in on demand, with dynamic text, rectangles, etc, etc. The
control alread described just takes an XML string to fill the template and
they the text and checkbox drawing is done on dynamically (and flash-free)
at runtime. It has saved me a lot of time, is OOP so easy to work with and
might interest some others.

-s


robert smith

unread,
Dec 26, 2002, 10:12:35 PM12/26/02
to
Hmm, I hadn't considered that, not setting Interpolation modes in my code.
Thanks, I will look into it.

It is definitely not just the size of the picturebox because you can set
that width or height to anything you want (and, oddly, anything over the
traditional VBClassic Integer - Int16 - will just force it to be that 32767
with no exception and no alert) so it does have to be in the GDI+.

I have that book, it *is* very good.

Thanks again.

-s
"james" <jjam...@earthlink.net> wrote in message
news:#D4HfrQrCHA.1080@TK2MSFTNGP10...

robert smith

unread,
Dec 26, 2002, 10:58:05 PM12/26/02
to
I repeat, with all sincerity ... "no offense aganst C#"

whew, I have to learn to stop being so vb-centric now that .net is here :)

-s


frank

unread,
Dec 29, 2002, 3:20:04 PM12/29/02
to
Yes, you are right about that. I have worked with both C++ and old VB, and I
think C# was influenced by old VB quite a bit. Especially when you look at
the whole IDE integration in VS.net. Sometimes I saw people use C++ to
create COM objects just because it was "macho", or they wanted the
experience, even though they could create the same things in VB in about the
quarter of the time. It is amazing how biased people can be. I don't deny my
preference to the C syntax, but I use any tool to get a job done.

I find the new keywords in VB.net for OOP too wordy, but functionally it is
almost identical to C#. I thought the language wars would die down now that
classes can be reused across languages. This did not happen.

"robert smith" <smithgetri...@smithvoice.com> wrote in message

news:u#hTKRVrCHA.2496@TK2MSFTNGP12...

0 new messages