By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,285 Members | 1,248 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,285 IT Pros & Developers. It's quick & easy.

A few GDI+ U/I questions

P: n/a
Question #1)
If I do Image.Save with the same filepath that I got the image from, it
bombs with "A generic error occurred in GDI+"
Any ideas? I prompt the user before overwriting, but if they want to do it,
I would like to offer the ability.

Question #2) I have my cropping working, using my own rubber banding
selector widget, but I am wondering how to best allow them to hold SHIFT and
maintain aspect ratio like Photoshop and others do? Any ideas on the math,
algorithm needed to do this. I'm sure it is simple just having one of those
days where I can't think of how to do it.

Thanks a lot,

Shane
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
#1 GDI+ FAQ

#2 Just use the X value of the mouse and make the rectangle height the the
width multiplied by the original width divide by the original height.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"SStory" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Question #1)
If I do Image.Save with the same filepath that I got the image from, it
bombs with "A generic error occurred in GDI+"
Any ideas? I prompt the user before overwriting, but if they want to do
it,
I would like to offer the ability.

Question #2) I have my cropping working, using my own rubber banding
selector widget, but I am wondering how to best allow them to hold SHIFT
and
maintain aspect ratio like Photoshop and others do? Any ideas on the
math,
algorithm needed to do this. I'm sure it is simple just having one of
those
days where I can't think of how to do it.

Thanks a lot,

Shane

Nov 21 '05 #2

P: n/a
Mr. Powell is indeed "The Man", up there with Rod Stephens and Richard
Mansfield for gdi information, but a from-here quickie on #1 is to call
GC.Collect. .Net locks the .FronFile opened file "in case it needs to
dynamically get more data" (as in for a multipage Tiff). However, if you
have grabbed the image and are holdng a clone then that lock gets in the
way. This is one of the few cases where calling GC.Collect - just after
loading the image to a local object - is a good solution.

Humbly: maybe the free Adobe eBook mentioned on this page would be of
interest? http://www.smithvoice.com/ispec_1.aspx

robert smith
kirkland, wa
www.smithvoice.com

"SStory" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Question #1)
If I do Image.Save with the same filepath that I got the image from, it
bombs with "A generic error occurred in GDI+"
Any ideas? I prompt the user before overwriting, but if they want to do
it,
I would like to offer the ability.

Question #2) I have my cropping working, using my own rubber banding
selector widget, but I am wondering how to best allow them to hold SHIFT
and
maintain aspect ratio like Photoshop and others do? Any ideas on the
math,
algorithm needed to do this. I'm sure it is simple just having one of
those
days where I can't think of how to do it.

Thanks a lot,

Shane

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.