locked
Drawing.Image on Web RRS feed

  • Question

  • User-1274603289 posted

     how can i write drawing.image out without save file to server ?

    Tuesday, April 21, 2009 6:47 AM

All replies

  • User187056398 posted

    Here's the basics:

     

        protected void Button1_Click(object sender, EventArgs e)
        {
            Bitmap MyBitmap = new Bitmap(100, 100);
    
            Graphics g = Graphics.FromImage(MyBitmap);
    
            g.DrawLine(Pens.Yellow, 0, 0, 100, 100);
            g.DrawLine(Pens.Red, 100, 0, 0, 100);
    
            MyBitmap.Save(Response.OutputStream, ImageFormat.Gif);
    
            g.Dispose();
            MyBitmap.Dispose();
        }
    
     
    Tuesday, April 21, 2009 9:02 AM
  • User-1274603289 posted

    i want to know about this line.

    MyBitmap.Save(Response.OutputStream, ImageFormat.Gif);
     
    what does it mean ? 
    it will save file to server right ?
     
    if that true..., it's ok but i want a way that not save file to my server
     
    thanks again to answer my question ^ ^ 
    Tuesday, April 21, 2009 12:55 PM
  • User854688209 posted

     The code provided by SGWellens won't save the file on the server, it will output directly to the browser.

    Tuesday, April 21, 2009 1:32 PM
  • User-1274603289 posted

     i'm got some exception. from line i'm ask.

    "A generic error occurred in GDI+"

     

    Tuesday, April 21, 2009 11:04 PM
  • User-1136466523 posted

    Hi,

    From the error message your provide, I suggest that you may refer the following post which may be helpful to you.

    http://www.velocityreviews.com/forums/t115183-upload-image-and-then-resize-it-a-generic-error-occurred-in-gdi.html

    Thanks.

    Wednesday, April 22, 2009 11:12 PM
  • User2077524089 posted

    Hi,

    according to my knowledge ,just check it out the outstream name that you got from response

    or else

    put that line in Try

    {   MyBitmap.Save(Response.OutputStream,ImageFormat.gif);

    }

    Catch(Exception ex){}

    Try this and let me know

     

    Thursday, April 30, 2009 5:27 AM