Gdi 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 a generic error occurred in gdi+. bitmap.save c# of this site About Us Learn more about Stack Overflow the company Business system.runtime.interopservices.externalexception (0x80004005): a generic error occurred in gdi+. Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask
How To Solve A Generic Error Occurred In Gdi+
Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign
A Generic Error Occurred In Gdi In C# Windows Application
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 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 system.runtime.interopservices.externalexception: a generic error occurred in gdi+. 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 resized bitmap oGraphics.DrawImage(originalBMP, 0, 0, thumbWidth, thumbHeight); Bitmap newBitmap = new Bitmap(thumbBMP); thumbBMP.Dispose(); thumbBMP = null; // Save the new graphic file to the server newBitmap.Save("~/image/thumbs/" + "t" + objPropBannerImage.ImageId, ImageFormat.Jpeg); oGraphics = Graphics.FromImage(bannerBMP); // Set the properties for the new graphic file oGraphics.SmoothingMode = SmoothingMode.AntiAlias; oGraphics.Interp
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta
A Generic Error Occurred In Gdi+ Windows 7
Discuss the workings and policies of this site About Us Learn more a generic error occured in gdi+. bitmap.save c# about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack a generic error occurred in gdi+. asp.net c# Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, http://stackoverflow.com/questions/15862810/a-generic-error-occured-in-gdi-in-bitmap-save-method helping each other. Join them; it only takes a minute: Sign up A generic error occurred in GDI+ at System.Drawing.Image.Save up vote 10 down vote favorite 1 Exception: A generic error occurred in GDI+. at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams) at System.Drawing.Image.Save(String filename, ImageFormat format) at System.Drawing.Image.Save(String filename) Code: byte[] bitmapData = new byte[imageText.Length]; MemoryStream streamBitmap; bitmapData http://stackoverflow.com/questions/22708150/a-generic-error-occurred-in-gdi-at-system-drawing-image-save = Convert.FromBase64String(imageText); streamBitmap = new MemoryStream(bitmapData); System.Drawing.Image img = Image.FromStream(streamBitmap); img.Save(path); We convert a base64 string into a MemoryStream and then create a System.Drawing.Image (Image.FromStream(streamBitmap)). At the end the image is saved in a temp file. The strange thing is that the problem seems to occur when the activity (number of concurrent users) is high on the web server and the problem is solved temporarily after an IISRESET or an application pool recycle... ==> Garbage collector issue ? I already checked the permission of the TEMP folder... c# asp.net .net image gdi+ share|improve this question edited Mar 28 '14 at 9:46 asked Mar 28 '14 at 8:59 Razor 62021223 add a comment| 3 Answers 3 active oldest votes up vote 9 down vote When you are loading an imagefrom a Stream, You have to keep the stream open for the lifetime of the image, see MSDN Image.FromStream. I think the exception is caused because the memory stream gets closed even before the image gets disposed. You can change your
ASP.NET Community Standup Forums Help Home/ASP.NET Forums/Retired Forums/nGallery (RETIRED)/A generic error http://forums.asp.net/t/624305.aspx?A+generic+error+occurred+in+GDI+ occurred in GDI+ A generic error occurred in GDI+ RSS 14 replies Last post Sep 15, 2011 02:12 AM by savindra.bandi ‹ Previous http://www.codeproject.com/Questions/672546/A-generic-error-occurred-in-GDIplus-VB-NET-WHILE-s Thread|Next Thread › Print Share Twitter Facebook Email Shortcuts Active Threads Unanswered Threads Unresolved Threads Support Options Advanced Search Reply jimmyLeander None a generic 0 Points 3 Posts A generic error occurred in GDI+ Jul 04, 2004 05:50 PM|jimmyLeander|LINK I received the foolowing message when attempting to upload a message. I do not have any .Net experience. Is there anyone out there that will take the time to give me a generic error a hand with this .Net error message? This appears to be a really nice looking and funtional image gallery and I would really enjoy using for family photos. Jimmy......................................................... A generic error occurred in GDI+. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: -------------------------------------------------------------------------------- [ExternalException (0x80004005): A generic error occurred in GDI+.] System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams) +582 nGallery.Lib.PhotoCache.GetScaledPicture() +1747 nGallery.Lib.PhotoCache.GetThumbnail() +66 nGallery.admin.addPicture.btnSubmit_ServerClick(Object sender, EventArgs e) +651 System
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 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 & 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 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 A generic error occurred in GDI+. VB.NET WHILE saving image from picturebox Rate this: Please Sign up or sign in to vote. See more: VB VB.NET please provide me solution for following code it shows GDI+ error on pic.save. Public Class Form1
Dim open As OpenFileDialog
Dim i As String
Dim img As Image = Nothing
Dim pic As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
open = New OpenFileDialog
open.Filter = "Image