Asp.net Bitmap Save Error
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 a generic error occurred in gdi c# image save Overflow the company Business Learn more about hiring developers or posting ads with us
A Generic Error Occurred In Gdi In C# Windows Application
Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a
How To Solve A Generic Error Occurred In Gdi+
community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up A Generic error occurs at GDI+ at Bitmap.Save() after using SaveFileDialog up vote 20 down
A Generic Error Occurred In Gdi+. Asp.net C#
vote favorite 3 I use the following code block with some more code inside the using block: using (System.Drawing.Bitmap tempImg = (System.Drawing.Bitmap)tempObj.GetData(System.Windows.Forms.DataFormats.Bitmap)) { // ... tempImg.Save("..\\..\\testdata\\tempImg.bmp", ImageFormat.Bmp); // ... } But I still get the error: A Generic Error occured at GDI+ only after I make some action which is not related to the code inside the using block. In other times this works well. Also the tempImg.bmp is a temporary a generic error occurred in gdi at system drawing image save in c# file, so I delete the tempImg.bmp within the using block itself. Since the tempImg is inside the using and this it's disposed, I think the locking problem should be solved. Can someone please let me know what is the mistake in this code? Edit: System.Drawing.Image to System.Drawing.Bitmap as the type of tempImg. Edit: I have identified I get this error only after SaveFileDialog is created and user clicks on 'Save'. c# bitmap save savefiledialog share|improve this question edited May 5 '11 at 9:32 asked Apr 28 '11 at 4:28 Dulini Atapattu 1,73642442 Why is tempImg Image and your cast Bitmap ? –V4Vendetta Apr 28 '11 at 4:33 Sorry, it should be corrected as SYstem.Drawing.Bitmap... thanks for comment –Dulini Atapattu Apr 28 '11 at 4:51 only after I make some action which is not related to the code does this involve reading/saving some other image ? –V4Vendetta Apr 28 '11 at 5:44 No, it only create an avi file using the Bitmap objects obtained from tempImg though a stream within the using block itselft and tempImg.bmp is deleted each time after obtaining the bitmap object. –Dulini Atapattu Apr 28 '11 at 6:31 So that might be the problem since its alr
here for a quick overview of the site Help Center Detailed answers to any questions c# picturebox image save a generic error occurred in gdi+ you might have Meta Discuss the workings and policies of this a generic error occured in gdi+. bitmap.save c# site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers system.runtime.interopservices.externalexception (0x80004005): a generic error occurred in gdi+. or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a http://stackoverflow.com/questions/5813633/a-generic-error-occurs-at-gdi-at-bitmap-save-after-using-savefiledialog community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ASP.NET error on Bitmap.Save “Exception (0x80004005): A generic error occurred in GDI+.” up vote 5 down vote favorite I have a function which first reads an image from disk, resizes it and then saves http://stackoverflow.com/questions/2431301/asp-net-error-on-bitmap-save-exception-0x80004005-a-generic-error-occurred-i to another directory. when i use the Bitmap.Save(directory + theimagename) it returns the error as i stated in the question title. i checked the directory is right, and the given image name doesn't exist in that dir. what is weird, is that the same code works great on the local machine. but when i upload it to my shared hosting space, it just doesn't work. the code is below. bmpOut = new Bitmap(Size, Size); Graphics g = Graphics.FromImage(bmpOut); g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.FillRectangle(Brushes.White, 0, 0, Size, Size); int topBottomPadding = 0; int leftRightPadding = 0; if (Size > lnNewWidth + 1) leftRightPadding = Convert.ToInt32((Size - lnNewWidth) / 2); else if (Size > lnNewHeight + 1) topBottomPadding = Convert.ToInt32((Size - lnNewHeight) / 2); g.DrawImage(loBMP, leftRightPadding, topBottomPadding, lnNewWidth, lnNewHeight); Bitmap bmp = new Bitmap(bmpOut); if (bmp != null) bmp.Save(ResizedOutput); // C:\Inetpub\vhosts\DomainName\httpdocs\ProductImages\500px\gigabyte_ga_ep45_ds4_profilelarge[1].jpg bmp.Dispose(); bmpOut.Dispose(); g.Dispose(); loBMP.Dispose(); stack trace: [ExternalException (0x80004005): A generic error occurred in GDI+.] System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters e
Tips/Tricks Top Articles Beginner Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article Competition Submit an article or tip Post your Blog quick answersQ&A Ask a http://www.codeproject.com/Questions/52709/C-Bitmap-Save-Generic-GDI-Error Question View Unanswered Questions View All Questions... C# questions Linux questions ASP.NET questions SQL questions VB.NET questions discussionsforums All Message Boards... Application Lifecycle> Running a Business Sales / Marketing Collaboration / Beta Testing Work Issues Design and Architecture ASP.NET JavaScript C / C++ / MFC> ATL / WTL / STL Managed C++/CLI C# Free Tools Objective-C and Swift Database Hardware a generic & Devices> System Admin Hosting and Servers Java .NET Framework Android iOS Mobile SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions Spam and Abuse Watch features Competitions News The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research Library CodeProject Stuff communitylounge Who's Who Most Valuable Professionals The Lounge The Insider News The a generic error Weird & The Wonderful The Soapbox Press Releases Non-English Language > General Indian Topics General Chinese Topics help What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Ask a Question All Questions All Unanswered FAQ C# Bitmap Save Generic GDI+ Error Rate this: Please Sign up or sign in to vote. See more: C# GDI This code is giving me problems: private void SaveBMP(Bitmap bmp)
{
bmp.Save(_project.MapFilePath);
} This line throws a generic GDI+ error. bmp.Save(_project.MapFilePath); Any ideas? quote: It means that the file path points to an image that has already been opened in GDI+. You need to be careful to close your images when you are done with them. There's tons of info on this on the web, but that's the core of all the info you'll find. Bugs in GDI+ cause it to hold a file open, unless you're very careful in how you use them. How do I close a bitmap image? Posted 16-J