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

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

问题描述

嗯,我已经很好地处理了画布上的几个图像,现在问题在于通过 Phonegap 导出到 iOS 上的照片库.我已经阅读了很多与 Phonegap API 相关的内容,以及很多测试,但没有结果.

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.

Phongap 有没有插件可以访问 IOS 中的照片库?我看到了一个 Android :(.

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

如果不是(我找到了 canvas2image.js)你对这个主题有哪些经验?

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

每一个信息都会被apreciated.

Every info will be apreciated.

万分感谢,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

在您的 html 中:

In your html:

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

然后在 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天全站免登陆