473,568 Members | 2,939 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A few GDI+ U/I questions

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
2 1478
#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*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote in message
news:%2******** *******@TK2MSFT NGP10.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
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*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote in message
news:%2******** *******@TK2MSFT NGP10.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2512
by: **ham | last post by:
I know that's an old dirty issue; GDI+ almost -the slowest part of the framework - has bothered many developers using it in animations. Even in managed C++ the performance is awful. Now, any dude out there does know any thing about this issue in VS 2005 + ..NET 2.0 ? Has Microsoft solved this performance problem, or we will have to again...
2
6098
by: °Ë´óɽÈË | last post by:
Hi guys, As you know, we can call SetROP2 to set the current foreground mix mode in GDI. But I doesn't work in GDI+. The step is: GetDC --> SetROP2 -->Graphics.FromDC, then draw sth by graphics object. How to realize it in GDI+?
4
5267
by: pixel | last post by:
hi GDI ExtFloodFill doesn't "see" GDI+ colors ..ToArgb() doesn't work at all any suggestions br pixel
5
4129
by: anonymous | last post by:
I'm writing a program that deals extensively with the printer. For the most part my application runs fine, but occasionally I run into some Exceptions. The most common exceptions I run into are NullReferenceException and InvalidOperationException : The object is currently in use elsewhere. Unfortunately this appears to be a race condition. ...
3
1417
by: James dean | last post by:
Is an updated version of Gdi+ being planned to complement the new beta trial version of Visual Studio 2005. Why is GraphicsPath slow? I cannot find good performance information about GDI+, can anyone help me out. Thanks in advance
1
5310
by: James dean | last post by:
Could someone explain how this works. I think the graphics card is used to do blitting and drawing shapes like rectangles. How does it draw using the Graphics card on the PC and why is this feature left out of GDI+?. *** Sent via Developersdex http://www.developersdex.com ***
6
6269
by: James dean | last post by:
I want a good site that will show clearly how much more functionality GDI+ has. I cannot seem to find anything other than sites that list "some" of the new functionality that GDI+ offers. A comprehensive list would be great.... *** Sent via Developersdex http://www.developersdex.com ***
10
1618
by: Jim Hubbard | last post by:
Can you use VB.Net to set a system-wide hook to intercept all GDI calls from GDI to the system's hardware? I want to intercept all GDI instructions sent to the system's hardware layer. As I understand it (and I may be missing something) GDI sends instructions to a DEVICE (which can be a printer or display unit or any device for which a...
7
5966
by: Marcin Rzeznicki | last post by:
Hello, Do you think it is legitimate practice to mix GDI+ and GDI calls (via Get/ReleaseHDC()) in paint event of a control? I've heard there is possibility of performance loss while "locking" Graphics object which is done as a side-effect to GetHDC() call - could you confirm? Another question that comes to my mind when planning mentioned...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7916
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8117
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7660
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5498
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2101
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.