Dynamically generated png images

Discussion in 'ASP .Net' started by Chris Jones, Jun 27, 2003.

  1. Chris Jones

    Chris Jones Guest

    I am creating a web page that dynamically generates an
    image, which is placed in an Image control. Everything
    works fine for .gif and .jpeg files. I would prefer
    using .png format, but that doesn't seem to work.

    Here's how it's setup.

    The Image control has URL property "image.aspx".

    The Page_Load method of image.aspx contains the code

    {
    //generate image
    Bitmap bitmap = ...
    //Return the image
    Response.ContentType = "image/png";
    bitmap.Save(Response.OutputStream,ImageFormat.Png);
    }

    If ContentType is "image/jpeg" and bitmap.Save's 2nd
    parameter is ImageFormat.Jpeg, everything works fine.
    Same for ContentType = "image/gif" and bitmap.Save's 2nd
    argument is ImageFormat.Gif. When the code appears as
    above, the Image control displays the dreaded "X" icon
    indicating that the image can't be found.

    Note that I can use a different version of the Save
    method for the bitmap to write the .png image to a file.
    I can then open the file successfully in IE.

    I am using VS.NET 2002 and .NET framework 1.0.

    Thanks for your help.

    Chris Jones
    LogexSoft
    Chris Jones, Jun 27, 2003
    #1
    1. Advertising

  2. Unless the browser you're working with supports PNG files, this is pretty
    much what you should expect.

    HTH,

    Kevin Spencer
    Microsoft FrontPage MVP
    Internet Developer
    http://www.takempis.com
    Big things are made up of
    lots of Little things.

    "Chris Jones" <> wrote in message
    news:0a7101c33cae$1a0bc1a0$...
    > I am creating a web page that dynamically generates an
    > image, which is placed in an Image control. Everything
    > works fine for .gif and .jpeg files. I would prefer
    > using .png format, but that doesn't seem to work.
    >
    > Here's how it's setup.
    >
    > The Image control has URL property "image.aspx".
    >
    > The Page_Load method of image.aspx contains the code
    >
    > {
    > //generate image
    > Bitmap bitmap = ...
    > //Return the image
    > Response.ContentType = "image/png";
    > bitmap.Save(Response.OutputStream,ImageFormat.Png);
    > }
    >
    > If ContentType is "image/jpeg" and bitmap.Save's 2nd
    > parameter is ImageFormat.Jpeg, everything works fine.
    > Same for ContentType = "image/gif" and bitmap.Save's 2nd
    > argument is ImageFormat.Gif. When the code appears as
    > above, the Image control displays the dreaded "X" icon
    > indicating that the image can't be found.
    >
    > Note that I can use a different version of the Save
    > method for the bitmap to write the .png image to a file.
    > I can then open the file successfully in IE.
    >
    > I am using VS.NET 2002 and .NET framework 1.0.
    >
    > Thanks for your help.
    >
    > Chris Jones
    > LogexSoft
    >
    >
    Kevin Spencer, Jun 27, 2003
    #2
    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. Chris Jones
    Replies:
    0
    Views:
    1,283
    Chris Jones
    Jun 25, 2003
  2. =?Utf-8?B?VGlt?=
    Replies:
    1
    Views:
    342
    WizyDig
    Dec 1, 2004
  3. =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=

    create png from generated html

    =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=, Aug 30, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    400
    =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=
    Aug 30, 2005
  4. Replies:
    0
    Views:
    469
  5. Keith Hughitt
    Replies:
    6
    Views:
    1,067
Loading...

Share This Page