简体   繁体   中英

gwt g2d: drawImage in ie8

I'm using g2d with gwt in order to implement some canvas functionalities. As the canvas implementation provided by gwt (I'm using version 2.4.0) is not supported by ie8, at least that is what I could experience, I decided to change to the before mentioned graphic library.

The issue arises when I try to draw a base64 image. I submit the following code:

Element img = DOM.createElement("img");
img.setAttribute("src", imagen.getBase64());
ImageElement imgElement = ImageElement.as(img);
surface.drawImage(imgElement, x, y, w, h);

This works well in IE9, but it doesn't in IE8. Despite of drawing the image, surface puts a blank square.

As you probably know, g2d is an implementation of excanvas.js, and after invoking drawImage an 'invalid poninter' js error arises.

Thanks in advance!

Edit:

As I could see into the javascript, I got the following error:

vmlStr.push(' ''>', '<g_vml_:image src="' + image.src + '"' , ..., ' />', 
'</g_vml_:group>');

This is part of excanvas.js code, just before finishing the drawing. What is retrieving "invalid pointer" error is image.src, it seems that the base64 is not being assigned to that attribute.

没关系,我找到了一种适用于所有浏览器的替代方法:在服务器端生成图像,然后将其编码为base64,然后可以在客户端的回调函数中对其进行检索。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM