Home > a generic > gdiplus bitmap save error

Gdiplus 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 a generic error occurred in gdi c# image save About Us Learn more about Stack Overflow the company Business Learn more how to solve a generic error occurred in gdi+ about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss

A Generic Error Occurred In Gdi In C# Windows Application

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 up A Generic error

A Generic Error Occurred In Gdi+. Asp.net C#

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 on folder, also tried to use a a generic error occured in gdi+. bitmap.save c# 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.InterpolationMode = InterpolationMode.HighQualityBicubic; // Draw the new graphic based on the resized bitmap oGraphics.DrawImage(originalBM

here for a quick overview of the site Help Center Detailed answers to any questions you might

C# Picturebox Image Save A Generic Error Occurred In Gdi+

have Meta Discuss the workings and policies of this site About system.runtime.interopservices.externalexception (0x80004005): a generic error occurred in gdi+. Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads a generic error occurred in gdi at system drawing image save in c# 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 million http://stackoverflow.com/questions/15862810/a-generic-error-occured-in-gdi-in-bitmap-save-method 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 200 down vote favorite 38 This seems to be a bit of an infamous error all over the web. So much so that I have been unable to http://stackoverflow.com/questions/1053052/a-generic-error-occurred-in-gdi-jpeg-image-to-memorystream 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.Infrastructure.PhotoEditor.ConvertImageToByteArray(Image imageToConvert) in C:\Users\Ian\SVN\Caldoo\Caldoo.Coordinator\PhotoEditor.cs:line 139 at C

> .NET Framework Class https://social.msdn.microsoft.com/Forums/vstudio/en-US/b15357f1-ad9d-4c80-9ec1-92c786cca4e6/bitmapsave-a-generic-error-occurred-in-gdi?forum=netfxbcl Libraries Question 0 Sign in to vote Hello All,I was just going to play around by generating some bitmaps programatically.I started http://weblogs.asp.net/anasghanem/solving-quot-a-generic-error-occurred-in-gdi-quot-exception off with this simple example, expecting everything to go smoothly, but have run into a strange error.The following code is by a generic no means good, just something simple and complete I would expect to work:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace BitmapOutput{    public partial class Form1 : Form    {        ///

        /// The picture i am drawing        ///         System.Drawing.Bitmap myBitmap;        ///         /// a generic error Graphics object for drawing        ///         System.Drawing.Graphics myGrafx;        public Form1()        {            InitializeComponent();            this.myBitmap = new Bitmap(800, 600);            this.myGrafx =                 System.Drawing.Graphics.FromImage(this.myBitmap);            this.DrawPicture();            this.ShowPicture();            this.SavePicture();        }        public void DrawPicture()        {            this.myGrafx.DrawEllipse(                new Pen(System.Drawing.Color.AliceBlue),                 new Rectangle(0, 0, 100, 100));        }        public void ShowPicture()        {            this.pictureBox1.Image = this.myBitmap;        }        public void SavePicture()        {            this.myBitmap.Save("Output\\out.bmp" ,                    System.Drawing.Imaging.ImageFormat.Bmp );        }    }}This runs fine until the SavePicture(...) function is called.I get the exception:"A generic error occurred in GDI+."at the this.myBitmap.Save(...); line.Most likely there is some detail that I have overlooked, and I appreciate it if anyone could point out to me what I could do to fix it.But, I'd like to think that this code woul

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 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. 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 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

 

Related content

a generic error occurred 5 7 7 hamachi

A Generic Error Occurred Hamachi table id toc tbody tr td div id toctitle Contents div ul li a href Evolve a li ul td tr tbody table p be there as you use your personal computer These problems will exist even if you're using the computer for years now These generally happen when surfing around the web When you think relatedl of it thoroughly these will issues will actually assist you know if kb the computer is having some issues and needs some care Several problems might get worse over tunngle download time To fix the problem you must

a generic error occurred in gdi

A Generic Error Occurred In Gdi table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi When Saving Image a li li a href A Generic Error Occurred In Gdi Act a li li a href A Generic Error Occurred In Gdi Asp Net a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any relatedl questions you might have Meta Discuss the workings and a generic error occurred in gdi bitmap save c policies of this site

a generic error occurred in gdi bitmap save png

A Generic Error Occurred In Gdi Bitmap Save Png table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi C Image Save a li li a href A Generic Error Occurred In Gdi Image Save Vb Net a li li a href Gdiplus Bitmap Save Png a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers relatedl to any questions you might have Meta Discuss c bitmap save a generic error occurred in gdi the workings and policies of

a generic error occurred in gdi outputstream

A Generic Error Occurred In Gdi Outputstream table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi Bitmap Save C a li li a href A Generic Error Occurred In Gdi In C Windows Application a li li a href A Generic Error Occurred In Gdi Windows a li li a href A Generic Error Occurred In Gdi Selenium a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you relatedl might have Meta Discuss the

a generic error occurred in gdi onpaint

A Generic Error Occurred In Gdi Onpaint table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi C Image Save a li li a href A Generic Error Occurred In Gdi At System Drawing Image Save a li li a href A Generic Error Occurred In Gdi Windows a li li a href A Generic Error Occurred In Gdi Vb a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the

a generic error occurred in gdi in asp net

A Generic Error Occurred In Gdi In Asp Net table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi Crystal Reports a li li a href A Generic Error Occurred In Gdi Windows a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any relatedl 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

a generic error occurred in gdi windows 7

A Generic Error Occurred In Gdi Windows table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi In C Windows Application a li li a href A Generic Error Occurred In Gdi C Image Save a li li a href A Generic Error Occurred In Gdi Vb a li li a href How To Solve A Generic Error Occurred In Gdi a li ul td tr tbody table p SQL Server Express resources Windows Server resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV

a generic error occurred in gdi windows xp

A Generic Error Occurred In Gdi Windows Xp table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi Windows a li li a href A Generic Error Occurred In Gdi C Image Save a li li a href A Generic Error Occurred In Gdi Crystal Reports a li li a href A Generic Error Occurred In Gdi Vb a li ul td tr tbody table p here for a quick overview of the site Help relatedl Center Detailed answers to any questions you might a generic error occurred in

a generic error occurred in gdi animated gif

A Generic Error Occurred In Gdi Animated Gif table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi At System Drawing Image Save a li li a href A Generic Error Occurred In Gdi Vb a li li a href A Generic Error Occurred In Gdi Selenium a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed relatedl answers to any questions you might have Meta Discuss a generic error occurred in gdi bitmap save c the workings and policies

asp net bitmap save a generic error occurred in gdi

Asp Net Bitmap Save A Generic Error Occurred In Gdi table id toc tbody tr td div id toctitle Contents div ul li a href How To Solve A Generic Error Occurred In Gdi a li li a href System runtime interopservices externalexception x A Generic Error Occurred In Gdi a li li a href A Generic Error Occurred In Gdi Windows a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to relatedl any questions you might have Meta Discuss the workings a generic error occurred in gdi c

asp.net bitmap save error

Asp net Bitmap Save Error table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi In C Windows Application a li li a href How To Solve A Generic Error Occurred In Gdi a li li a href A Generic Error Occurred In Gdi Asp net C a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings relatedl and policies of this site About Us Learn more about Stack

bitmap memorystream error

Bitmap Memorystream Error table id toc tbody tr td div id toctitle Contents div ul li a href Image Save C a li li a href C Image From Byte Array a li ul td tr tbody table p GDI error' if the stream is closed Visual Studio Languages NET Framework Visual C relatedl Question Sign in to vote I'm doing a c bitmap parameter is not valid memorystream bit of processing of an image I just need to rotate it a generic error occurred in gdi c image save increase the size and convert to bit-per-pixel I'm just having

bitmap.save memorystream gdi error

Bitmap save Memorystream Gdi Error table id toc tbody tr td div id toctitle Contents div ul li a href How To Solve A Generic Error Occurred In Gdi a li li a href A Generic Error Occurred In Gdi In C Windows Application a li li a href System runtime interopservices externalexception x A Generic Error Occurred In Gdi a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might relatedl have Meta Discuss the workings and policies of this a generic error occurred in

bitmap save to stream a generic error occurred in gdi

Bitmap Save To Stream A Generic Error Occurred In Gdi table id toc tbody tr td div id toctitle Contents div ul li a href How To Solve A Generic Error Occurred In Gdi a li li a href System runtime interopservices externalexception x A Generic Error Occurred In Gdi a li li a href A Generic Error Occurred In Gdi Windows a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to relatedl any questions you might have Meta Discuss the workings c bitmap save a generic error occurred

c bitmap save a generic error occurred in gdi

C Bitmap Save A Generic Error Occurred In Gdi table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi In C Windows Application a li li a href How To Solve A Generic Error Occurred In Gdi a li li a href A Generic Error Occurred In Gdi Asp net C a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to relatedl any questions you might have Meta Discuss the a generic error occurred in gdi c image

c# a generic error occurred in gdi image save

C A Generic Error Occurred In Gdi Image Save table id toc tbody tr td div id toctitle Contents div ul li a href How To Solve A Generic Error Occurred In Gdi a li li a href C Picturebox Image Save A Generic Error Occurred In Gdi a li li a href A Generic Error Occurred In Gdi Windows a li ul td tr tbody table p here for a quick overview of the site relatedl Help Center Detailed answers to any questions you a generic error occurred in gdi image save vb net might have Meta Discuss the

c# bitmap save generic gdi error

C Bitmap Save Generic Gdi Error table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi In C Windows Application a li li a href C Picturebox Image Save A Generic Error Occurred In Gdi a li li a href A Generic Error Occurred In Gdi Windows a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to relatedl any questions you might have Meta Discuss the workings c bitmap save a generic error occurred in gdi and policies

bmp save error

Bmp Save Error table id toc tbody tr td div id toctitle Contents div ul li a href C Bmp Save a li li a href How To Solve A Generic Error Occurred In Gdi a li li a href A Generic Error Occurred In Gdi In C Windows Application a li li a href C Picturebox Image Save A Generic Error Occurred In Gdi a li ul td tr tbody table p 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

error gdi generic in occurred

Error Gdi Generic In Occurred table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi C a li li a href A Generic Error Occurred In Gdi Act a li li a href A Generic Error Occurred In Gdi Asp Net a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you relatedl might have Meta Discuss the workings and policies of a generic error occurred in gdi image save this site About Us Learn more

externalexception a generic error

Externalexception A Generic Error table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi Bitmap Save C a li li a href A Generic Error Occurred In Gdi In C Windows Application a li li a href How To Solve A Generic Error Occurred In Gdi a li li a href System runtime interopservices externalexception A Generic Error Occurred In Gdi a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss

externalexception a generic error occurred in

Externalexception A Generic Error Occurred In table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi In C Windows Application a li li a href A Generic Error Occurred In Gdi Asp net C a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have relatedl Meta Discuss the workings and policies of this site a generic error occurred in gdi c image save About Us Learn more about Stack Overflow the company Business

externalexception a generic error occurred

Externalexception A Generic Error Occurred table id toc tbody tr td div id toctitle Contents div ul li a href System runtime interopservices externalexception x A Generic Error Occurred In Gdi a li li a href A Generic Error Occurred In Gdi In C Windows Application a li li a href How To Fix A Generic Error Occurred In Gdi a li ul td tr tbody table p 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 relatedl Learn more

gdi bitmap error

Gdi Bitmap Error table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occured In Gdi Bitmap save C a li li a href System runtime interopservices externalexception x A Generic Error Occurred In Gdi a li ul td tr tbody table p here for a quick overview of the site relatedl Help Center Detailed answers to any questions you a generic error occurred in gdi c image save might have Meta Discuss the workings and policies of this a generic error occurred in gdi in c windows application site About Us

gdi error eoutofresources copy bitmap

Gdi Error Eoutofresources Copy Bitmap table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi Bitmap save C a li li a href A Generic Error Occurred In Gdi In C Windows Application a li li a href C Picturebox Image Save A Generic Error Occurred In Gdi a li li a href A Generic Error Occured In Gdi Bitmap save C a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta

gdi error on website

Gdi Error On Website table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi Bitmap save C a li li a href How To Solve A Generic Error Occurred In Gdi a li li a href System runtime interopservices externalexception A Generic Error Occurred In Gdi a li li a href A Generic Error Occurred In Gdi Windows a li ul td tr tbody table p here for a quick overview of relatedl the site Help Center Detailed answers to a generic error occurred in gdi c image save

gdi error

Gdi Error table id toc tbody tr td div id toctitle Contents div ul li a href How To Solve A Generic Error Occurred In Gdi a li li a href A Generic Error Occurred In Gdi In C Windows Application a li li a href A Generic Error Occurred In Gdi Windows a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions relatedl you might have Meta Discuss the workings and policies a generic error occurred in gdi bitmap save c of this site About Us

image save error

Image Save Error table id toc tbody tr td div id toctitle Contents div ul li a href How To Solve A Generic Error Occurred In Gdi a li li a href A Generic Error Occurred In Gdi Asp net C a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the relatedl workings and policies of this site About Us Learn more a generic error occurred in gdi c image save about Stack Overflow the company Business Learn more about hiring

interopservices externalexception a generic error occurred in

Interopservices Externalexception A Generic Error Occurred In table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi In C Windows Application a li li a href How To Fix A Generic Error Occurred In Gdi a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might relatedl have Meta Discuss the workings and policies of this site a generic error occurred in gdi c image save About Us Learn more about Stack Overflow the company

interopservices externalexception a generic error

Interopservices Externalexception A Generic Error table id toc tbody tr td div id toctitle Contents div ul li a href System runtime interopservices externalexception x A Generic Error Occurred In Gdi a li li a href A Generic Error Occurred In Gdi Bitmap Save C a li li a href A Generic Error Occurred In Gdi In C Windows Application a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed relatedl answers to any questions you might have Meta a generic error occurred in gdi c image save Discuss the workings

interopservices externalexception a generic error occurred

Interopservices Externalexception A Generic Error Occurred table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi C Image Save a li li a href A Generic Error Occurred In Gdi Bitmap Save C a li li a href How To Fix A Generic Error Occurred In Gdi a li li a href A Generic Error Occurred In Gdi At System Drawing Image Save In C a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers relatedl to any questions

net bitmap save error

Net Bitmap Save Error table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi C Image Save a li li a href A Generic Error Occurred In Gdi Image Save Vb Net a li li a href A Generic Error Occurred In Gdi At System Drawing Image Save In C a li li a href A Generic Error Occurred In Gdi Windows a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers relatedl to any questions you might have

photorecord gdi error

Photorecord Gdi Error table id toc tbody tr td div id toctitle Contents div ul li a href A Generic Error Occurred In Gdi Bitmap Save C a li li a href A Generic Error Occurred In Gdi In C Windows Application a li li a href How To Solve A Generic Error Occurred In Gdi a li li a href A Generic Error Occurred In Gdi Asp net C a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions relatedl you might have Meta Discuss the