画布到PhotoLibrary [Phonegap] [英] Canvas to PhotoLibrary [Phonegap]

查看:132
本文介绍了画布到PhotoLibrary [Phonegap]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我已经处理了很好的几个图像到画布上,现在的问题在于输出到照片库在iOS通过Phonegap。我读过很多关于Phonegap API,很多测试,但没有结果。



有没有任何插件的Phongap允许访问的照片库在IOS?我看到一个Android:(。



如果没有(我找到了canvas2image.js),这是你对这个主题的经验吗?


$ b h2_lin>解决方案

我读这个,认为有多难?。



所以我快速入侵了一个。 / p>

让我知道如果它可以正常工作。



https://github.com/devgeeks/Canvas2ImagePlugin



示例



在您的HTML中:

 < canvas id =myCanvaswidth =165pxheight =145px> ; / canvas> 

然后在 onDeviceReady

  function onDeviceReady()
{
var canvas2ImagePlugin = window.plugins.canvas2ImagePlugin;
}

然后在函数中保存您的画布:

  //其中myCanvasId =='myCanvas'(上面的画布的id)
function mySavingFunction(myCanvasId){
canvas2ImagePlugin.saveImageDataToLibrary(
function(msg){
console.log(msg);
},
function(err){
console.log(err);
},
myCanvasId
);
}


Well, I have dealed quite well with several images onto canvas and now the questions lays in exporting to Photo library on iOS throught Phonegap. I've read a lot relates to the Phonegap API, and lot of tests as well, but no results.

Is there any plugin for Phongap which allows to access the photo library in IOS? I saw one for Android :(.

If not (I found canvas2image.js) which are your experiences about this topic?

Every info will be apreciated.

Thanks in avance, DGM.-

解决方案

I read this and thought "how hard could it be?".

So I hacked one up real quick.

Let me know if it works OK.

https://github.com/devgeeks/Canvas2ImagePlugin

Example

In your html:

<canvas id="myCanvas" width="165px" height="145px"></canvas>

then in onDeviceReady:

function onDeviceReady()
{
    var canvas2ImagePlugin = window.plugins.canvas2ImagePlugin;
}

then in the function to save your canvas:

// where myCanvasId == 'myCanvas' (the id of the canvas above)
function mySavingFunction(myCanvasId) {
    canvas2ImagePlugin.saveImageDataToLibrary(
        function(msg){
            console.log(msg);
        }, 
        function(err){
            console.log(err);
        }, 
        myCanvasId
    );
}

这篇关于画布到PhotoLibrary [Phonegap]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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