Dynamically Generating Imagemaps??

Discussion in 'ASP .Net Web Controls' started by Philip Wilson, Jan 8, 2005.

  1. Hello,

    I am trying to dynamically generate an imagemap in vb.net. I have managed to generate the image easily enough by creating a .aspx page that returns the generated image and then using the <img src="dynamicimage.aspx" imagemap=...> to put that image onto the page.

    I am using the following method in the dynamicimage.aspx to return the image:

    Response.ContentType = "image/gif"

    AttBitmap.Save(Response.OutputStream, ImageFormat.Gif)


    Now I need to generate the imagemap HTML code. I thought the logical place to generate this code is in the dynamicimage.aspx page since I will already be working with the coordinates to create the image, so I can just create the HTML code as I create the image.

    But then, what is the best way to get that HTML code back into the main aspx page that contains the <img src="dynamicimage.aspx">.

    I would like to do it all on the one page by assigning the Bitmap object to an image on the page and then just outputting the imagemap code to the same page, however I have not seen any way of inserting the generated image into the existing page along with HTML code. If I use an ASP:Image I don't seem to have any way of specifying an imagemap and I can't see a way of linking my Bitmap object to a <IMG> without saving it out as a file first.

    I am fairly new to this, any ideas would be greatly appreciated.

    Cheers,
    Phil
     
    Philip Wilson, Jan 8, 2005
    #1
    1. Advertisements

  2. how about using 'Response.BinaryWrite(Image.SaveGIFStream)' after the call to 'Response.ContentType'

    that way you can use 'IMG id="Image" src="dynamicimage.aspx"' in the calling page

    make sense?

    -BB
     
    Brian Burgess, Jan 10, 2005
    #2
    1. Advertisements

  3. sorry ... make that:
    'Image.Save(Response.OutputStream, ImageFormat.Gif)' instead of 'Response.BinaryWrite(Image.SaveGIFStream)'

    I copied the wrong line ... :-$


    -BB

    how about using 'Response.BinaryWrite(Image.SaveGIFStream)' after the call to 'Response.ContentType'

    that way you can use 'IMG id="Image" src="dynamicimage.aspx"' in the calling page

    make sense?

    -BB
     
    Brian Burgess, Jan 10, 2005
    #3
  4. Yeah, but isn't that what I have got already?
    What I want to know is, if I create the <Map ....> HTML code in the dynamicimage.aspx page. What is the best way to transfer that text back to the page that is calling the dynamicimage.aspx.

    I will have a page that contains the '<IMG id="Image" src="dynamicimage.aspx" usemap=#mapname...>' but under that I will have to put the HTML code for the map which I will also be creating in the dynamicimage.aspx page.

    Basically I am needing to return two components to the calling page. The Image and the imagemap HTML Code. I can do the image, I'm just not sure how best to get the HTML text back.

    Does that make sense?

    I thought about adding a parameter to the dynamicimage.aspx page so that I can get it to return either the image or the imagemap code and then calling it twice. That just seemed a little redundant.

    Thanks,
    Phil

    sorry ... make that:
    'Image.Save(Response.OutputStream, ImageFormat.Gif)' instead of 'Response.BinaryWrite(Image.SaveGIFStream)'

    I copied the wrong line ... :-$


    -BB

    how about using 'Response.BinaryWrite(Image.SaveGIFStream)' after the call to 'Response.ContentType'

    that way you can use 'IMG id="Image" src="dynamicimage.aspx"' in the calling page

    make sense?

    -BB
     
    Philip Wilson, Jan 11, 2005
    #4
  5. Ah yes .. perhaps it is what you already have... DOHH

    I my case I have only two files: 1) The imagemap HTML Code file that calls
    2) the dynamicimage.aspx. This way it is automatically 'returned' to the
    HTML code after the image is processed.

    Would this way work for you?
    ... or do you need the actual text stream of HTML code as well?

    -BB


    dynamicimage.aspx page. What is the best way to transfer that text back to
    the page that is calling the dynamicimage.aspx.
    src="dynamicimage.aspx" usemap=#mapname...>' but under that I will have to
    put the HTML code for the map which I will also be creating in the
    dynamicimage.aspx page.
    Image and the imagemap HTML Code. I can do the image, I'm just not sure how
    best to get the HTML text back.
    can get it to return either the image or the imagemap code and then calling
    it twice. That just seemed a little redundant.
    managed to generate the image easily enough by creating a .aspx page that
    returns the generated image and then using the <img src="dynamicimage.aspx"
    imagemap=...> to put that image onto the page.place to generate this code is in the dynamicimage.aspx page since I will
    already be working with the coordinates to create the image, so I can just
    create the HTML code as I create the image.object to an image on the page and then just outputting the imagemap code to
    the same page, however I have not seen any way of inserting the generated
    image into the existing page along with HTML code. If I use an ASP:Image I
    don't seem to have any way of specifying an imagemap and I can't see a way
     
    Brian Burgess, Jan 11, 2005
    #5
  6. Does this mean that your imagemap HTML is static and you just dynamically create the image?

    In my case, I am wanting to dynamically create the both the imagemap and the image. I think I am just going to to try calling the dynamicimage.aspx file twice and get it to return either the image or the imagemap depending on a parameter. I don't think it will add too much overhead.

    Thanks for your help,
    Phil

    Ah yes .. perhaps it is what you already have... DOHH

    I my case I have only two files: 1) The imagemap HTML Code file that calls
    2) the dynamicimage.aspx. This way it is automatically 'returned' to the
    HTML code after the image is processed.

    Would this way work for you?
    ... or do you need the actual text stream of HTML code as well?

    -BB


    dynamicimage.aspx page. What is the best way to transfer that text back to
    the page that is calling the dynamicimage.aspx.
    src="dynamicimage.aspx" usemap=#mapname...>' but under that I will have to
    put the HTML code for the map which I will also be creating in the
    dynamicimage.aspx page.
    Image and the imagemap HTML Code. I can do the image, I'm just not sure how
    best to get the HTML text back.
    can get it to return either the image or the imagemap code and then calling
    it twice. That just seemed a little redundant.
    managed to generate the image easily enough by creating a .aspx page that
    returns the generated image and then using the <img src="dynamicimage.aspx"
    imagemap=...> to put that image onto the page.place to generate this code is in the dynamicimage.aspx page since I will
    already be working with the coordinates to create the image, so I can just
    create the HTML code as I create the image.object to an image on the page and then just outputting the imagemap code to
    the same page, however I have not seen any way of inserting the generated
    image into the existing page along with HTML code. If I use an ASP:Image I
    don't seem to have any way of specifying an imagemap and I can't see a way
     
    Philip Wilson, Jan 12, 2005
    #6
  7. Hi Philip,

    sorry to take so long to reply .. I've been out about day and a half.

    Yes in my case the imagemap HTML is a static page that calls the dynamic
    image aspx page. the dynamic page merely loads a base JPG file, then
    overlays text at dynamic positions, then writes the binary image data back
    to the static HTML (imagemap) page.

    I think your on the right track already .. since you can only write one
    stream out to the outgoing HTTP response stream.

    good luck

    -BB


    the image. I think I am just going to to try calling the dynamicimage.aspx
    file twice and get it to return either the image or the imagemap depending
    on a parameter. I don't think it will add too much overhead.
     
    Brian Burgess, Jan 14, 2005
    #7
  8. Philip Wilson

    Jack71 Guest

    try this:

    Dim stx As String
    stx += "<map name=^ToscanaMap^>"
    stx += "<area shape=^RECT^ coords=^107,202,172,227^
    href=^grosseto.htm^>"
    stx += "<area shape=^RECT^ coords=^65,143,126,170^
    href=^livorno.htm^>"
    stx += "<area shape=^RECT^ coords=^133,145,180,170^
    href=^siena.htm^>"
    stx += "<area shape=^RECT^ coords=^183,113,240,136^
    href=^arezzo.htm^>"
    stx += "<area shape=^RECT^ coords=^70,111,107,134^
    href=^pisa.htm^>"
    stx += "<area shape=^RECT^ coords=^108,76,155,98^
    href=^prato.htm^>"
    stx += "<area shape=^RECT^ coords=^40,54,87,79^ href=^lucca.htm^>"
    stx += "<area shape=^RECT^ coords=^153,40,213,63^
    href=^firenze.htm^>"
    stx += "<area shape=^RECT^ coords=^83,33,138,58^
    href=^pistoia.htm^>"
    stx += "<area shape=^RECT^ coords=^9,2,119,27^
    href=^massa_carrara.htm^>"
    stx += "</map>"
    stx += "<IMG alt=^^ src=^images/Toscana_Intera.gif^
    useMap=^#ToscanaMap^ border=^0^>"
    stx = stx.Replace("^", """")

    PanelToscana.Controls.Clear()
    PanelToscana.Controls.Add(New LiteralControl(stx))
     
    Jack71, May 4, 2005
    #8
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.