toDataUrl - 保存图像在IE? [英] toDataUrl - saving Images in IE?

查看:103
本文介绍了toDataUrl - 保存图像在IE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了很多时间使用KineticJS建立装扮游戏,我似乎已经陷入了最后的障碍。

I have spent a lot of time building a dress-up game using KineticJS and I seem to have fallen at the final hurdle.

我创建了一个快照'按钮,我想让用户将画布打印到窗口或选项卡。以下是我的代码片段:

I have created a 'Snapshot' button which I wanted to allow my users to print the canvas to a window or tab. Here is a snippet of my code:

Camera.prototype.takeSnapshot = function()
{

    var backgroundLayer = this.controller.view.getBackgroundLayer();
    var backgroundContext = backgroundLayer.getContext();

    var manikinLayer = this.controller.view.getManikinLayer();
    var manikinCanvas = manikinLayer.getCanvas();

    //combine background and 'manikin' layers
    backgroundContext.drawImage(manikinCanvas,0 ,0);

    //open data URL in new window
    var manikinImageUrl = backgroundLayer.getCanvas().toDataURL('image/png');
    window.open(manikinImageUrl);
};



现在确定你已经猜到了,这适用于FF,Chrome,Safari for Win,但不是IE或IOS Safari。做了一些研究,我相信所有版本如果IE平面不支持这个功能?

Now as im sure you will have guessed already, this works in FF, Chrome, Safari for Win, but not IE or IOS Safari. Having done some research I believe all versions if IE flat out dont support this functionality?

我只是在寻找专家来确认这是否为真。

I am just looking for an expert to confirm if this is true or not.

告诉我如何在打印出来之前将backgroundLayer和ManikinLayer融合在一起?我得到的错误值无法转换为任何:HTMLImageElement,HTMLCanvasElement,HTMLVideoElement'在第五行代码。

Also could someone please tell me how to fuse the the backgroundLayer and ManikinLayer together before they are printed out? I am getting the errpr 'Value could not be converted to any of: HTMLImageElement, HTMLCanvasElement, HTMLVideoElement' on the 5th line of code.

任何帮助非常赞赏,因为我接近junking的项目后投入了这么多的努力!

Any help much appreciated as I am close to junking the project after having put in so much effort!

推荐答案

在新窗口中,创建一个源元素设置为dataURL的图片元素:

In your new window, create an image element with the source set to your dataURL:

    var win=window.open();
    win.document.write("<img src='"+manikinImageUrl+"'/>");

这篇关于toDataUrl - 保存图像在IE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆