Javascript PhoneGap:是否将图像从画布保存到本地图像库?
我有一个在Android/iOS上运行的PhoneGap/Cordova应用程序。应用程序在HTML5画布元素中创建图像。此画布将在浏览器中导出为图像Javascript PhoneGap:是否将图像从画布保存到本地图像库?,javascript,android,ios,cordova,Javascript,Android,Ios,Cordova,我有一个在Android/iOS上运行的PhoneGap/Cordova应用程序。应用程序在HTML5画布元素中创建图像。此画布将在浏览器中导出为图像 如何将浏览器中生成的图像保存到Android/iOS本地图像库?请尝试使用iOS自定义插件。将图像从phonegap传递到本机(目标C)。将图像保存到相册中 在iOs项目中添加2个文件SaveToPhotoAlbum.h和SaveToPhotoAlbum.m SaveToPhotoAlbum.h #import <Foundation/Fo
如何将浏览器中生成的图像保存到Android/iOS本地图像库?请尝试使用iOS自定义插件。将图像从phonegap传递到本机(目标C)。将图像保存到相册中 在iOs项目中添加2个文件SaveToPhotoAlbum.h和SaveToPhotoAlbum.m SaveToPhotoAlbum.h
#import <Foundation/Foundation.h>
#import <Cordova/CDVPlugin.h>
@interface SaveToPhotoAlbum : CDVPlugin {
}
- (void) saveToPhotoAlbum:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
@end
saveToPhotoAlbum.js
(function(cordova) {
/**
* Constructor
*/
function SaveToPhotoAlbum() {}
SaveToPhotoAlbum.prototype.saveToPhotoAlbum = function(successCallback, failCallback, uri) {
console.log('SaveToPhotoAlbum.js: saveToPhotoAlbum: uri:' + uri);
if (!uri) {
if (typeof failCallback === 'function') {
failCallback('uri not provided');
}
return;
}
cordova.exec(
successCallback,
failCallback,
"SaveToPhotoAlbum",
"saveToPhotoAlbum",
[uri]
);
};
/**
* Install function
*/
SaveToPhotoAlbum.install = function() {
if ( !window.plugins ) {
window.plugins = {};
}
if ( !window.plugins.SaveToPhotoAlbum ) {
window.plugins.SaveToPhotoAlbum = new SaveToPhotoAlbum();
}
};
/**
* Add to Cordova constructor
*/
if (cordova && cordova.addConstructor) {
cordova.addConstructor(SaveToPhotoAlbum.install);
} else {
console.log("SaveToPhotoAlbum Cordova Plugin could not be installed.");
return null;
}
})(window.PhoneGap || window.Cordova || window.cordova);
并以以下方式调用html文件:
var imageSource = $('#widgetScreen_widgetContainer [name="mobileimage_66"]')[0].src;
window.plugins.SaveToPhotoAlbum.saveToPhotoAlbum(photoSuccess, photoFail, imageSource);
如果我没有画布但仍要保存彩信图像,我该怎么办?canvas2image是插件的名称,但它会将本地或远程图像保存到iOS保存的相册中。我可以使用此插件保存使用var image=new image()创建的图像吗?
var imageSource = $('#widgetScreen_widgetContainer [name="mobileimage_66"]')[0].src;
window.plugins.SaveToPhotoAlbum.saveToPhotoAlbum(photoSuccess, photoFail, imageSource);