Click to See Complete Forum and Search --> : html IMG element - how to access underlying bitmap


Todd.Harvey
August 30th, 2002, 11:30 AM
I have an ActiveX control, and I can pass an image to it. In Visual Basic, for example, the syntax is:
Call PicShower.SetDirectMeta (Image1.Picture)
"Image1" is an image display control that you use in Visual Basic.
I hope there is some what to do similarly in html/JavaScript, but I have tried many permutations in both JavaScript, VBScript, going to the IMG object from the document, and I have not been lucky so far.

I wonder if someone knows how to get to the image.

I have a test page at:
http://www.sayslaw.com/Thynx/C/com/PictureATL/PicShower.htm

The ActiveX control is safe, I got it from CodeProject, and the link to its explanation is provided.

Any help you provide would be appreciated.

anupam kant
September 2nd, 2002, 12:09 AM
this is the way you can get the image src:
in this code I want to access the image's src on click of the button.:

<img id=say src=test.gif >
<input type=buton value="get image" onclick="getImageName()">

<script language=javascript>
function getImageName()
{
var imgSrc = window.document.all['say'].src;
alert(imgSrc);
}
</script>


hope this helps:)

Todd.Harvey
September 2nd, 2002, 09:04 PM
thanks for the reply, Anupam

But I'm trying to get something a little harder. (the src is the text string that is the name of the image, right? I'm trying to get the image itself, because the control is going to display the image.

I'm thinking this maybe be a bad thing to attempt, but I can do it in VB, in C++, and I kind of wanted to get it to work in a scripting language, but it might not be possible.

anupam kant
September 3rd, 2002, 12:06 AM
Okay, I understand
but let us try this also:

function showName()
{
var imgPath = window.document.all['say'].src;
//.alert(imgPath)
var newImg = new Image();
newImg.src =imgPath;
alert(newImg) //.this is the required image object. <--
}

Todd.Harvey
September 3rd, 2002, 10:36 AM
Anupam,
thanks much for looking at this

I think perhaps I misunderstood how some of this works after having such an easy experience with Visual Basic (maybe VB is the perfect environment for cobbling together ActiveX objects). When I got it to work with VC++, I had to send the ActiveX object an IPicture object, so I had to convert the Bitmap to IPicture.

I think perhaps none of the above relates to JavaScript.

I notice that some other similar applications don't attempt to send the actual image to the COM object, but they give it the path to the image and let it load the image itself. That's probably a smarter and simpler way to go about it.