A few GDI+ U/I questions

  • Thread starter Thread starter SStory
  • Start date Start date
S

SStory

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
 
#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.
 
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
 

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

Back
Top