I have the following code in my page and it keeps conking out at the line where I try GETIMAGEDATA
<script type="text/vbscript" id="PreviewRangeFromPalette"> Function PreviewRangeFromPalette(evt) Dim oMouseX Dim oMouseY Dim oCanvas1 Dim oContext1 Dim oImageData Dim oDataRect Dim X, R, G, B, A oMouseX = parseInt(evt.offsetX) oMouseY = parseInt(evt.offsetY) UpdateMouseLocation oMouseX, oMouseY Set oCanvas1 = document.getElementById("ColorPaletteImage") Set oContext1 = oCanvas1.getContext("2d") Set oImageData = oContext1.GetImageData(0, 0, oCanvas1.width-1, oCanvas1.height-1) 'msgbox(oImageData.height) OK - This returns the correct height 'msgbox(oImageData.width) OK - This returns the correct width oDataRect = oImageData.Data 'X = ((oMouseY * oCanvas1.width) + oMouseX) * 4 'R = oDataRect.data(X) 'G = oDataRect.data(X + 1) 'B = oDataRect.data(X + 2) 'A = oDataRect.data(X + 3) 'window.document.getElementById("PreviewColor").style.BackgroundColor = "#" & Hex(R) & Hex(G) & Hex(B) Set oCanvas1 = Nothing Set oContext1 = Nothing Set oImagedata = Nothing 'Set oDataRect = Nothing End Function</script>
The HTML I used is
<canvas id="ColorPaletteImage" height="256px" width="256px" style="width: 256px; height: 256px;" onmousemove="PreviewRangeFromPalette(event)"><noscript> Your browser does not support the HTML5 canvas object!</noscript></canvas>
Why does it conk out on the getimagedata statement?
I receive the following error
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
Timestamp: Thu, 23 May 2013 00:06:38 UTC
Message: Could not complete the operation due to error 800a01bd.
Line: 181
Char: 1
Code: 0
URI: http://localhost:56248/EShopAdmin/SelectColor?OId=300&CId='n%2Fa'
Please can someone point me in the correct direction to resolve this using VBSCRIPT
DocZaf