How to return a Jpg Image as result of a function?

Discussion in 'ASP .Net' started by Dexter, Sep 23, 2004.

  1. Dexter

    Dexter Guest

    Hello all,
    I have a Class with a function that create a imagem, i need that this
    function return a jpg imagem. Somebody know how to make this?



    Thanks



    Dexter
    Dexter, Sep 23, 2004
    #1
    1. Advertising

  2. Dexter

    Hans Kesting Guest

    Dexter wrote:
    > Hello all,
    > I have a Class with a function that create a imagem, i need that this
    > function return a jpg imagem. Somebody know how to make this?
    >
    >
    >
    > Thanks
    >
    >
    >
    > Dexter


    The Bitmap class is independent of encoding. You can however convert
    the image to a byte[] with some encoding (like jpeg):

    Bitmap img = ....
    MemoryStream io = new MemoryStream();
    img.Save(io, ImageFormat.Jpeg);
    byte[] ba = io.GetBuffer();

    (namespaces used: System.Drawing, System.Drawing.Imaging, System.IO)

    Hans Kesting
    Hans Kesting, Sep 23, 2004
    #2
    1. Advertising

  3. You will probably need to write your own HttpHandler which will generate the
    content-type of jpeg and stuff that to the Response.OutputStream.
    Some old code (http://www.devweek.com/code/esposito_graphics.zip) has some
    code that shows how to retrieve the image data out of the database and
    stream it as the image.
    I believe there is some code by Jeff Prosise as well which does similar
    thing.



    --
    Girish Bharadwaj
    http://msmvps.com/gbvb
    "Dexter" <> wrote in message
    news:%23Pg$...
    > Hello all,
    > I have a Class with a function that create a imagem, i need that this
    > function return a jpg imagem. Somebody know how to make this?
    >
    >
    >
    > Thanks
    >
    >
    >
    > Dexter
    >
    >
    Girish bharadwaj, Sep 23, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roland
    Replies:
    0
    Views:
    1,042
    Roland
    May 12, 2004
  2. Matthias
    Replies:
    5
    Views:
    413
    Whitecrest
    Jun 1, 2004
  3. Yannick

    ASP changes Big JPG -> Small JPG

    Yannick, Feb 2, 2004, in forum: ASP General
    Replies:
    6
    Views:
    147
    Tim Williams
    Feb 3, 2004
  4. Vilmar Brazão de Oliveira
    Replies:
    14
    Views:
    328
    Aaron Bertrand [MVP]
    Mar 5, 2004
  5. Michael Tan
    Replies:
    32
    Views:
    937
    Ara.T.Howard
    Jul 21, 2005
Loading...

Share This Page