Generic Error Gdi
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company
A Generic Error Occurred In Gdi Image Save Vb Net
Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs a generic error occurred in gdi+. bitmap.save c# Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, how to solve a generic error occurred in gdi+ just like you, helping each other. Join them; it only takes a minute: Sign up “A generic error occurred in GDI+” when attempting to use Image.Save up vote 4 down vote favorite 1 I am developing an
A Generic Error Occurred In Gdi In C# Windows Application
Outlook 2010 Add-In, and am loading an image from a serialized XML file. The image loads fine, and am able to assign it to a pictureBox object on a Winform no problem. The object is saved in [XmlIgnore] public Bitmap Image { get { return this.templateImage; } set { this.templateImage = value; } } When, I attempt to save the physical file onto the harddisk however, I am doing: string filePath = Path.Combine(dirPath, item.Id
A Generic Error Occurred In Gdi+ Windows 7
+ ".jpg"); try { item.Image.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg); } catch (Exception e) { Debug.WriteLine("DEBUG::LoadImages()::Error attempting to create image::" + e.Message); } and am getting an A generic error occurred in GDI+. I've checked the write permissions on the folder, and it does have write permissions. I'm unsure what is wrong here. I've also changed the ImageFormat to bmp and png and so forth to see if it was a conversion problem... but it isn't. Would anybody suggest something to try? c# .net gdi+ share|improve this question asked Feb 14 '13 at 1:56 Magnum 98721031 2 There are so many possible reasons for this error.. its very frustrating. Some things to try: 1) Write to a different folder. 2) Check the dimensions of the file. If it's too large (somewhere in the range of 4000x4000) it will also throw this error. 3) Make sure the file is not in use by anything else (including your code). –Simon Whitehead Feb 14 '13 at 2:04 @Simon Whitehead thanks for the suggestions. I tried writing to the parent directory, also to C:\temp but that didn't work. The dimensions of the file is 64x64 pixels (small). #3 is the only one I didn't try yet. I guess I could copy the Image to a new object and try writing that one. Will report momentarily. –Magn
here for a quick overview of the site Help Center Detailed answers to any questions you might a generic error occurred in gdi at system drawing image save in c# have Meta Discuss the workings and policies of this site
A Generic Error Occurred In Gdi+. Asp.net C#
About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting a generic error occured in gdi+. bitmap.save c# ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 http://stackoverflow.com/questions/14866603/a-generic-error-occurred-in-gdi-when-attempting-to-use-image-save million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up A Generic error occured in GDI+ in Bitmap.Save method up vote 26 down vote favorite 8 I am working on to upload and same a thumnail copy of that image in a thumbnail forder. I am using following http://stackoverflow.com/questions/15862810/a-generic-error-occured-in-gdi-in-bitmap-save-method link: http://weblogs.asp.net/markmcdonnell/archive/2008/03/09/resize-image-before-uploading-to-server.aspx but newBMP.Save(directory + "tn_" + filename); is causing exception "A generic error occurred in GDI+." I have tried to give permission on folder, also tried to use a new separate bmp object when saving. Edit: protected void ResizeAndSave(PropBannerImage objPropBannerImage) { // Create a bitmap of the content of the fileUpload control in memory Bitmap originalBMP = new Bitmap(fuImage.FileContent); // Calculate the new image dimensions int origWidth = originalBMP.Width; int origHeight = originalBMP.Height; int sngRatio = origWidth / origHeight; int thumbWidth = 100; int thumbHeight = thumbWidth / sngRatio; int bannerWidth = 100; int bannerHeight = bannerWidth / sngRatio; // Create a new bitmap which will hold the previous resized bitmap Bitmap thumbBMP = new Bitmap(originalBMP, thumbWidth, thumbHeight); Bitmap bannerBMP = new Bitmap(originalBMP, bannerWidth, bannerHeight); // Create a graphic based on the new bitmap Graphics oGraphics = Graphics.FromImage(thumbBMP); // Set the properties for the new graphic file oGraphics.SmoothingMode = SmoothingMode.AntiAlias; oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic; // Draw the new graphic based on the
have a write permission on some directory. For example, if you are trying to save the Image from the memory stream to the file system , you may get that error. I also faced that error when I was using Infragistics charts http://weblogs.asp.net/anasghanem/solving-quot-a-generic-error-occurred-in-gdi-quot-exception control , the control was trying to create a temporary chart in ChartImages folder and my application was not given the write permission. Please if you are using XP, make sure to add write permission for the aspnet account on that folder. If you are using windows server (2003,2008) or Vista, make sure that add write permission for the Network service account. Hope it help some one. 23 Comments Na, _one_ of the possible errors could be the one, you described. generic error The "Generic error" in fact is used in certain scenarios. It means "we were to lazy to write better error return code". This really sucks. Uwe - Saturday, February 28, 2009 8:44:55 PM Well, at least that's based on my experience and on the problems i faced. I know that there is many other causes of that problem,but that's what i know until this time. anas - Saturday, February 28, 2009 8:57:28 PM I think it's the most common error so permissions a generic error should always be checked first. SGWellens - Saturday, February 28, 2009 9:18:12 PM It might not be that you don't have write permissions, but a sharing violation might be in effect. Common scenario that this happens: 1) Read an image into a Bitmap object 2) Manipulate the bitmap 3) Wanting to write back the bitmap to overwrite the original image file you read in step 1. This can happen because the Bitmap implementation seems to be as lazy as possible. It can choose the just remember the path that was the source of the image bits (or even a handle to the opened file they came from). This then means your software has the original image file open, causing this problem when you try to overwrite it in step three. To work around this use some simple code in an intermediate step (let's say 1a) that creates a new, blank Bitmap object with the same width/height/colordepth as the image you read. Then, get a Graphics object for the blank image and draw (BitBlt, basically) the loaded image onto the blank image. Then, dispose the loaded image. This gets you a Bitmap object that contains the content of the loaded image actually stored in memory, without any link to the original image file. Then, work on the Bitmap the way you like and you can easily save it back over the original file in step 3 without sharing violations. (If you have write perm