Dynamically Generating Imagemaps??

P

Philip Wilson

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
 
B

Brian Burgess

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
 
B

Brian Burgess

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
 
P

Philip Wilson

Yeah, but isn't that what I have got already?
Response.ContentType = "image/gif"

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

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
 
B

Brian Burgess

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


Philip Wilson said:
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
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
 
P

Philip Wilson

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


Philip Wilson said:
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
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
 
B

Brian Burgess

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


Philip Wilson said:
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.
 
J

Jack71

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))
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top