Professional Web Applications Themes

Add a Bitmap ??? - ASP.NET General

I need to add a dynamical!! generated bitmap to an image button! What is the way to do it? The ImageButton offers only the URL property. But this are physical file paths. Dim new_bitmap As Bitmap = New Bitmap(850, 200) Dim image_button As New System.Web.UI.WebControls.ImageButton Thanks a lot Rob...

  1. #1

    Default Add a Bitmap ???

    I need to add a dynamical!! generated bitmap to an image
    button! What is the way to do it? The ImageButton offers
    only the URL property. But this are physical file paths.

    Dim new_bitmap As Bitmap = New Bitmap(850, 200)

    Dim image_button As New System.Web.UI.WebControls.ImageButton

    Thanks a lot

    Rob
    Robert Guest

  2. #2

    Default Re: Add a Bitmap ???

    The problem you have is that your working in the server side's memory... and
    so the image you're creating and using is, the server's buffer. When the
    request from the client to the server is made to pass it a picture, it needs
    to be a file that's requested, or the server won't know how to send it, and
    the client won't know how to receive it and show it.

    The only way you can do this is to first stream out the buffer, (i.e, save
    the bitmap to disk), then take that URL you've just saved the file too and
    pass that to the image button's URL.
    I'd suggest using something like in the ASP page...

    <A HREF="somefolder/somefile"><IMG BORDER=no ID=myImage
    SRC="images/myTempPick.jpg"></A>

    then when you've gotten the bitmap and saved it, something like... (aspx.vb
    file)

    dim ClientScript as String = ""
    ClientScript += "<SCRIPT language=javascript>" & vbNewLine
    ClientScript += " doent.all.myImage.src = " & stringImageURL &
    vbNewLine ' where stringImageURL is a string containing your image
    location you've saved out
    ClientScript += "</SCRIPT>
    RegisterStartupScript( "ImageChange", ClientScript )

    This code then writes the client side script to change your image URL from
    the TempPick to whatever pic you now want. Note that I used HTML's standard
    <IMG> rather than the <ASP:...>, I haven't played much with the ASP.net
    controls in this way so am not sure what they'll do, try it!

    hope that helps, and works!

    Dan.


    "Robert" <robert_dxgmx.com> wrote in message
    news:09d901c3452c$32d281c0$a501280aphx.gbl...
    > I need to add a dynamical!! generated bitmap to an image
    > button! What is the way to do it? The ImageButton offers
    > only the URL property. But this are physical file paths.
    >
    > Dim new_bitmap As Bitmap = New Bitmap(850, 200)
    >
    > Dim image_button As New System.Web.UI.WebControls.ImageButton
    >
    > Thanks a lot
    >
    > Rob

    Daniel Bass Guest

  3. #3

    Default Re: Add a Bitmap ???

    You don't want a Bitmap. You want an image format that IS supported by
    browsers, such as JPG or GIF. What you need to do is to create an ASPX page
    that uses Response.BinaryWrite() to write the binary image to the Response.
    This ASPX page must also set the ContentType to "image/jpg" or "image/gif"
    to inform the browser that it is not an ASPX page that is being returned,
    but an image. Your image button can then use the URL of the ASPX page as the
    URL to the image.

    HTH,

    Kevin Spencer
    Microsoft FrontPage MVP
    Internet Developer
    [url]http://www.takempis.com[/url]
    Some things just happen.
    Everything else occurs.

    "Robert" <robert_dxgmx.com> wrote in message
    news:09d901c3452c$32d281c0$a501280aphx.gbl...
    > I need to add a dynamical!! generated bitmap to an image
    > button! What is the way to do it? The ImageButton offers
    > only the URL property. But this are physical file paths.
    >
    > Dim new_bitmap As Bitmap = New Bitmap(850, 200)
    >
    > Dim image_button As New System.Web.UI.WebControls.ImageButton
    >
    > Thanks a lot
    >
    > Rob

    Kevin Spencer Guest

  4. #4

    Default Re: Add a Bitmap ???

    The May/June 2003 issue of CoDe (component developer magazine) had some
    great articles on doing things of this nature. Basically, you need to use
    the System.Drawing and System.Drawing.Imaging libraries. Use the source of
    your image as an aspx page with a Response.ContentType = "image/jpeg" or
    "image/gif" etc. I use something like this in a few of my pages <img
    src="paint.aspx"> to create some dynamic images.

    I don't want to violate copyright laws by repeating the source code that's
    in there,
    "Robert" <robert_dxgmx.com> wrote in message
    news:09d901c3452c$32d281c0$a501280aphx.gbl...
    > I need to add a dynamical!! generated bitmap to an image
    > button! What is the way to do it? The ImageButton offers
    > only the URL property. But this are physical file paths.
    >
    > Dim new_bitmap As Bitmap = New Bitmap(850, 200)
    >
    > Dim image_button As New System.Web.UI.WebControls.ImageButton
    >
    > Thanks a lot
    >
    > Rob

    Kenn Ghannon Guest

Similar Threads

  1. Replies: 0
    Last Post: November 23rd, 04:58 AM
  2. How to cut out bitmap ???
    By nguyentuananh in forum Macromedia Flash Ad Development
    Replies: 1
    Last Post: February 22nd, 07:38 PM
  3. text to bitmap
    By Somnifer in forum Macromedia Director Basics
    Replies: 4
    Last Post: April 14th, 12:48 PM
  4. Bitmap Transparency
    By wrand@mac.com in forum Macromedia Freehand
    Replies: 0
    Last Post: August 13th, 11:32 PM
  5. sequence bitmap
    By saly_d2000 webforumsuser@macromedia.com in forum Macromedia Fireworks
    Replies: 0
    Last Post: August 9th, 06:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139