Dropping custom graphic on a page


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Dropping custom graphic on a page

  1. #1
    Rob Lowney Guest

    Dropping custom graphic on a page


    Good Day,

    I am creating a GIF image on the fly via code and end up with a bitmap object.
    I now need to place the image on a web page.

    Currently I'm using the save method to save it to disk with a unique file
    name then displaying that file name in a regular old image. I would like
    to find a way to place the image on the screen without first having to save
    a file on the file system. Does anybody have any ideas/sample code on how
    to get this done?

    Thanks,

    Rob.

  2. #2
    Constance J. Petersen Guest

    Re: Dropping custom graphic on a page

    Hi Rob,

    "Rob Lowney" <rob.lowney@xwave.com> wrote in message
    news:3b5b1fc0$1@news.devx.com...
    > I am creating a GIF image on the fly via code and end up with a bitmap

    object.
    > I now need to place the image on a web page.
    > Currently I'm using the save method to save it to disk with a unique file
    > name then displaying that file name in a regular old image. I would like
    > to find a way to place the image on the screen without first having to

    save
    > a file on the file system. Does anybody have any ideas/sample code on how
    > to get this done?


    I've done this by first saving the image, as you have. Because the page it's
    going to is HTML based, it stands to reason that you would need to first
    save the file in a browser compatible format such as gif, jpg, or png.
    --
    Constance Petersen, DevX newsgroup section leader
    SoftMedia Artisans, Inc.
    http://www.smartisans.com
    Visual Basic.NET Internet Black Book
    ISBN: 1-58880-078-4



  3. #3
    Rob Lowney Guest

    Re: Dropping custom graphic on a page


    "Constance J. Petersen" <constance@smartisans.com> wrote:
    >Hi Rob,
    >
    >"Rob Lowney" <rob.lowney@xwave.com> wrote in message
    >news:3b5b1fc0$1@news.devx.com...
    >> I am creating a GIF image on the fly via code and end up with a bitmap

    >object.
    >> I now need to place the image on a web page.
    >> Currently I'm using the save method to save it to disk with a unique file
    >> name then displaying that file name in a regular old image. I would like
    >> to find a way to place the image on the screen without first having to

    >save
    >> a file on the file system. Does anybody have any ideas/sample code on

    how
    >> to get this done?

    >
    >I've done this by first saving the image, as you have. Because the page

    it's
    >going to is HTML based, it stands to reason that you would need to first
    >save the file in a browser compatible format such as gif, jpg, or png.


    I am doing this now... Saving as a GIF. I want to do this without first
    saving the image to disk, thus not having to give the user write access to
    the system.

  4. #4
    Russell Jones Guest

    Re: Dropping custom graphic on a page

    You can avoid saving the image to disk by following this procedure:

    1. Write the image tag out with its src attribute containing a URL back to
    your WebForm, for example, if your WebForm is
    http://yourServer/yourApp/somePage.aspx, you could use the URL
    http://yourServer/yourApp/somePage.aspx?getImage=True

    The browser will then call the src URL to get the image data, which will
    execute your page for the second time. You can tell the difference by
    checking in the Page_Load event for the getImage QueryString value. If it's
    "True" then create and return the image by setting the ResponseType to
    image/gif (or whatever file format you're creating). Then, create the
    graphic and Save it to the Response object. For example, this line sends a
    bitmap to the client as a GIF-formatted image:

    bmp.Save(Response.OutputStream, imgFormat.Gif)

    Russell Jones
    Sr. Web Development Editor,
    DevX.com


    "Rob Lowney" <rob.lowney@xwave.com> wrote in message
    news:3b5c2116$1@news.devx.com...
    >
    > "Constance J. Petersen" <constance@smartisans.com> wrote:
    > >Hi Rob,
    > >
    > >"Rob Lowney" <rob.lowney@xwave.com> wrote in message
    > >news:3b5b1fc0$1@news.devx.com...
    > >> I am creating a GIF image on the fly via code and end up with a bitmap

    > >object.
    > >> I now need to place the image on a web page.
    > >> Currently I'm using the save method to save it to disk with a unique

    file
    > >> name then displaying that file name in a regular old image. I would

    like
    > >> to find a way to place the image on the screen without first having to

    > >save
    > >> a file on the file system. Does anybody have any ideas/sample code on

    > how
    > >> to get this done?

    > >
    > >I've done this by first saving the image, as you have. Because the page

    > it's
    > >going to is HTML based, it stands to reason that you would need to first
    > >save the file in a browser compatible format such as gif, jpg, or png.

    >
    > I am doing this now... Saving as a GIF. I want to do this without first
    > saving the image to disk, thus not having to give the user write access to
    > the system.




  5. #5
    Rob Lowney Guest

    Re: Dropping custom graphic on a page


    Perfect... Works like a charm.

    Thanks.

    Rob


    "Russell Jones" <arj1@northstate.net> wrote:
    >You can avoid saving the image to disk by following this procedure:
    >
    >1. Write the image tag out with its src attribute containing a URL back

    to
    >your WebForm, for example, if your WebForm is
    >http://yourServer/yourApp/somePage.aspx, you could use the URL
    >http://yourServer/yourApp/somePage.aspx?getImage=True
    >
    >The browser will then call the src URL to get the image data, which will
    >execute your page for the second time. You can tell the difference by
    >checking in the Page_Load event for the getImage QueryString value. If it's
    >"True" then create and return the image by setting the ResponseType to
    >image/gif (or whatever file format you're creating). Then, create the
    >graphic and Save it to the Response object. For example, this line sends

    a
    >bitmap to the client as a GIF-formatted image:
    >
    >bmp.Save(Response.OutputStream, imgFormat.Gif)
    >
    >Russell Jones
    >Sr. Web Development Editor,
    >DevX.com



  6. #6
    Constance J. Petersen Guest

    Re: Dropping custom graphic on a page

    Hi Russell,

    "Russell Jones" <arj1@northstate.net> wrote in message
    news:3b5c69e1$1@news.devx.com...
    > bmp.Save(Response.OutputStream, imgFormat.Gif)


    Very cool!
    --
    Constance Petersen, DevX newsgroup section leader
    SoftMedia Artisans, Inc.
    http://www.smartisans.com
    Visual Basic.NET Internet Black Book
    ISBN: 1-58880-078-4



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center