Output Dynamic Graphic from Webcontrol

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jonathan Wood

    Output Dynamic Graphic from Webcontrol

    I've figured out how to create an image on the fly on my Website. Once
    created, I write the image to the page using code like this:

    Bitmap bm = [...]
    [...]
    Response.Conten tType = "image/jpeg";
    bm.Save(Respons e.OutputStream, ImageFormat.Jpe g);

    The code I have does indeed display the graphic, but the page shows nothing
    else. I need to write the image to a location within my Web page.

    My preference would be to create a Web control, that I can embed in the
    page, and then write the image from the control. However, the control's
    Render handler provides an HtmlTextWriter argument, which does not have an
    OutputStream property.

    How can I output the graphic as the control's output?

    Thanks.

    Jonathan

  • nick chan

    #2
    Re: Output Dynamic Graphic from Webcontrol

    your control needs to output an Image location as a string
    then, another page will actually load the image
    u can either create another aspx page, or read up about ashx/axd

    On May 26, 12:49 am, "Jonathan Wood" <jw...@softcirc uits.comwrote:
    I've figured out how to create an image on the fly on my Website. Once
    created, I write the image to the page using code like this:
    >
      Bitmap bm = [...]
      [...]
      Response.Conten tType = "image/jpeg";
      bm.Save(Respons e.OutputStream, ImageFormat.Jpe g);
    >
    The code I have does indeed display the graphic, but the page shows nothing
    else. I need to write the image to a location within my Web page.
    >
    My preference would be to create a Web control, that I can embed in the
    page, and then write the image from the control. However, the control's
    Render handler provides an HtmlTextWriter argument, which does not have an
    OutputStream property.
    >
    How can I output the graphic as the control's output?
    >
    Thanks.
    >
    Jonathan

    Comment

    • marss

      #3
      Re: Output Dynamic Graphic from Webcontrol

      On May 25, 7:49 pm, "Jonathan Wood" <jw...@softcirc uits.comwrote:
      How can I output the graphic as the control's output?
      1. Add new Generic Handler to the project. Name it, for example,
      "Handler1".

      2. Put the code for image creation inside of ProcessRequest method.
      void ProcessRequest( HttpContext context)
      {
      //create image
      Bitmap bm = [...]
      [...]
      context.Respons e.ContentType = "image/jpeg";
      bm.Save(context .Response.Outpu tStream, ImageFormat.Jpe g);
      }

      3.Use it as an ordinary image url
      <asp:Image ImageUrl="~/Handler1.ashx" ...

      Regards,
      Mykola
      http://marss.co.ua - Casual ideas for web development

      Comment

      • Jonathan Wood

        #4
        Re: Output Dynamic Graphic from Webcontrol

        Wow. New stuff for me. Will take me a while to figure it all out but looks
        interesting. Thanks!

        Jonathan

        "marss" <marss.ua@gmail .comwrote in message
        news:2d0dc952-4726-4f95-b02d-9d6ef59e72d5@r6 6g2000hsg.googl egroups.com...
        On May 25, 7:49 pm, "Jonathan Wood" <jw...@softcirc uits.comwrote:
        >
        >How can I output the graphic as the control's output?
        >
        1. Add new Generic Handler to the project. Name it, for example,
        "Handler1".
        >
        2. Put the code for image creation inside of ProcessRequest method.
        void ProcessRequest( HttpContext context)
        {
        //create image
        Bitmap bm = [...]
        [...]
        context.Respons e.ContentType = "image/jpeg";
        bm.Save(context .Response.Outpu tStream, ImageFormat.Jpe g);
        }
        >
        3.Use it as an ordinary image url
        <asp:Image ImageUrl="~/Handler1.ashx" ...
        >
        Regards,
        Mykola
        http://marss.co.ua - Casual ideas for web development

        Comment

        • Munna

          #5
          Re: Output Dynamic Graphic from Webcontrol

          On May 27, 10:09 am, "Jonathan Wood" <jw...@softcirc uits.comwrote:
          Wow. New stuff for me. Will take me a while to figure it all out but looks
          interesting. Thanks!
          >
          Jonathan
          >
          "marss" <marss...@gmail .comwrote in message
          >
          news:2d0dc952-4726-4f95-b02d-9d6ef59e72d5@r6 6g2000hsg.googl egroups.com...
          >
          On May 25, 7:49 pm, "Jonathan Wood" <jw...@softcirc uits.comwrote:
          >
          How can I output the graphic as the control's output?
          >
          1. Add new Generic Handler to the project. Name it, for example,
          "Handler1".
          >
          2. Put the code for image creation inside of ProcessRequest method.
          void ProcessRequest( HttpContext context)
          {
          //create image
          Bitmap bm = [...]
          [...]
          context.Respons e.ContentType = "image/jpeg";
          bm.Save(context .Response.Outpu tStream, ImageFormat.Jpe g);
          }
          >
          3.Use it as an ordinary image url
          <asp:Image ImageUrl="~/Handler1.ashx" ...
          >
          Regards,
          Mykola
          http://marss.co.ua- Casual ideas for web development
          Hi

          here is few links about dynamic image display that will help you kick
          start




          Best of luck
          Munna



          Comment

          Working...