Dynamically generated png images

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Jones

    Dynamically generated png images

    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.Conten tType = "image/png";
    bitmap.Save(Res ponse.OutputStr eam,ImageFormat .Png);
    }

    If ContentType is "image/jpeg" and bitmap.Save's 2nd
    parameter is ImageFormat.Jpe g, 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
    cvjones17@yahoo .com

  • Kevin Spencer

    #2
    Re: Dynamically generated png images

    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

    Big things are made up of
    lots of Little things.

    "Chris Jones" <cvjones17@yaho o.com> wrote in message
    news:0a7101c33c ae$1a0bc1a0$a50 1280a@phx.gbl.. .[color=blue]
    > 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.Conten tType = "image/png";
    > bitmap.Save(Res ponse.OutputStr eam,ImageFormat .Png);
    > }
    >
    > If ContentType is "image/jpeg" and bitmap.Save's 2nd
    > parameter is ImageFormat.Jpe g, 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
    > cvjones17@yahoo .com
    >[/color]


    Comment

    Working...