Saving image to the existing file throws "A generic error occurred in GDI+" error.

Posted by ryan on Stack Overflow See other posts from Stack Overflow or by ryan
Published on 2010-12-21T03:23:32Z Indexed on 2010/12/22 16:54 UTC
Read the original article Hit count: 164

Filed under:
|
|

i am trying to create a overlapped image using different images,then saving to a particular location. so that i can use generated image(overlapped img) in my telerik reporting. it is important to me to save the overlapped image to the same location with same name. but generating this overlapped image second time throws throws "A generic error occurred in GDI+" error.

Please help me with this.

It seems i can not override the existing image file. i tried deleting the existing image every time i generate the new one. but its not allowing me deleting the file ,may be it is used by telerik reporting.

Here is the image create method which takes the baseimage path, sectionimage path and the reportimage path (this is the target locationenter code here)

    public static void Creat(List<string> sectionNames, string reportImagePath, string baseImagePath) {

var file = Image.FromFile(baseImagePath);
            Graphics g = Graphics.FromImage(file);

            foreach (var sectionName in sectionNames) {
                var image = Image.FromFile(sectionName);
                g.DrawImage(image, new PointF(0.0F, 0.0F));
            }
      file.Save(reportImagePath, ImageFormat.Png);
       file.Dispose();
        }

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about image