A Generic Error Occurred In Gdi In Asp Net
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings a generic error occurred in gdi bitmap save c# and policies of this site About Us Learn more about Stack Overflow a generic error occurred in gdi c# image save the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation a generic error occurred in gdi in c# windows application 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, helping each other. Join them; it a generic error occurred in gdi+ at system drawing image save 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 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+."
A Generic Error Occurred In Gdi+ Crystal Reports
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 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 = Graph
here for a quick overview of the site Help Center Detailed answers to any questions you
A Generic Error Occurred In Gdi+ Windows 7
might have Meta Discuss the workings and policies of this site a generic error occurred in gdi+ vb About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or a generic error occurred in gdi+ selenium 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 community of http://stackoverflow.com/questions/15862810/a-generic-error-occured-in-gdi-in-bitmap-save-method 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up A generic error occurred in GDI+, JPEG Image to MemoryStream up vote 198 down vote favorite 38 This seems to be a bit of an infamous error all over the web. So much so that I have http://stackoverflow.com/questions/1053052/a-generic-error-occurred-in-gdi-jpeg-image-to-memorystream been unable to find an answer to my problem as my scenario doesn't fit. An exception gets thrown when I save the image to the stream. Weirdly this works perfectly with a png but gives the above error with jpg and gif which is rather confusing. Most similar problem out there relate to saving images to files without permissions. Ironically the solution is to use a memory stream as I am doing.... public static byte[] ConvertImageToByteArray(Image imageToConvert) { using (var ms = new MemoryStream()) { ImageFormat format; switch (imageToConvert.MimeType()) { case "image/png": format = ImageFormat.Png; break; case "image/gif": format = ImageFormat.Gif; break; default: format = ImageFormat.Jpeg; break; } imageToConvert.Save(ms, format); return ms.ToArray(); } } More detail to the exception. The reason this causes so many issues is the lack of explanation :( System.Runtime.InteropServices.ExternalException was unhandled by user code Message="A generic error occurred in GDI+." Source="System.Drawing" ErrorCode=-2147467259 StackTrace: at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams) at System.Drawing.Image.Save(Stream stream, ImageFormat format) at Caldoo.Infrastru
here for a quick overview of the site Help Center Detailed answers to any http://stackoverflow.com/questions/19509367/a-generic-error-occurred-in-gdi questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers 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 generic a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up a generic error occurred in GDI up vote 0 down vote favorite public static string DrawImage(string WorkDirectory, string oldImage, string WaterMarkImage, string waterMarkText, int XCoord, int YCoord, string NewImageName) { MemoryStream a generic error msNew = new MemoryStream(); MemoryStream msOut = new MemoryStream(); Bitmap bmp = new Bitmap(WorkDirectory + "\\" + oldImage); Bitmap bmpWm = new Bitmap(WorkDirectory + "\\" + WaterMarkImage); Bitmap bmpTemp = new Bitmap(bmp); Graphics canvas = Graphics.FromImage(bmpTemp); bmp.Dispose(); try { using (Graphics gr = Graphics.FromImage(bmpTemp)) { gr.DrawImage(bmpWm, new Rectangle(XCoord, YCoord, bmpWm.Width, bmpWm.Height), 0, 0, bmpWm.Width, bmpWm.Height, GraphicsUnit.Pixel); } } catch(Exception ex) { string errorMessage = "Error occurred during submission."; return errorMessage; } bmpTemp.Save(WorkDirectory + "\\" + NewImageName, ImageFormat.Png); bmpTemp.Dispose(); return WorkDirectory + "\\" + NewImageName; } Hi, this code is working fine in local server ,when putting this code on the live server than ,i am getting the error "a generic error occurred in GDI+". so how can solve this error. asp.net asp.net-mvc c#-4.0 razor share|improve this question asked Oct 22 '13 at 5:04 user2753984 11 GDI+ image manipulation and asp.net is tricky (from own experience), check inner exception, see alperguc.blogspot.in/2008/11/… –Hans Derks Oct 22