Bitmap.Save error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #1

    Bitmap.Save error

    Hi.

    Im trying to save an Image using C#, and I've created a code that, as far as I can see, should work.

    Yet it keeps throwing a GDI+ generic Exception, without any usable error details. It doesn't matter what format I'm trying to save in, it always throws the exeption.

    I'm using C# Express 2005 on Vista, if that matters.

    Here is the code
    Code:
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.Drawing.Drawing2D;
    ...
    private void SaveImage(object sender, EventArgs eArgs)
    {
        Bitmap tmp = new Bitmap(200, 200);
        Graphics tmpG = Graphics.FromImage(tmp);
    
        tmpG.FillEllipse(Brushes.Black, new Rectangle(10, 10, 180, 180));
        tmpG.Save();
    
        tmp.Save("C:\\myimg.jpg", ImageFormat.Jpeg);
    }
    Any help would be great.
    Thx.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Just found the problem.

    Turns out I didn't have permission to write to C:\
    Some security thing in Vista.

    Comment

    Working...