Manoj Tambe

Manoj Tambe

  • NA
  • 14
  • 32.2k

A generic error occurred in GDI+

Sep 27 2011 10:37 AM
This is my Code
This code is working fine for the .jpeg/.Gif format

but i want to save image to .png format

this code gives Error A generic error occurred in GDI+

public override void ExecuteResult(ControllerContext context)
    {
        PageHeading c = new PageHeading();
        //Captcha c = new Captcha();
        c.Text = _captchaText;
        c.Width = 685;
        c.Height = 50;
        c.FamilyName = "FlemishScript BT";

        HttpContextBase cb = context.HttpContext;

        //MemoryStream MemStream = new MemoryStream();

        cb.Response.Clear();
        cb.Response.ContentType = "image/png";
        c.Image.Save(cb.Response.OutputStream, System.Drawing.Imaging.ImageFormat.png);
        //c.Image.Save(cb.Response.OutputStream, ImageFormat.png);
        c.Dispose();
}

Answers (5)