|
本帖最后由 西兹兹 于 2015-9-23 12:42 编辑
1、是否苦恼拍照OOM闪退?
2、是否头疼SD卡路径问题?
3、是否在被不同OS版本和机型兼容性折磨?
4、是否需要自动判断并旋转图片?
5、是否需要在手机端指定压缩到<200KB?
以下附件工程是android自定义模块源码工程: dist目录 yolanda.zip 是自定义模块压缩包;
代码示例
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0,user-scalable=0">
- <title>APICloud</title>
- <link rel="stylesheet" type="text/css" href="../css/base.css" />
- <link rel="stylesheet" type="text/css" href="../css/common.css" />
- </head>
- <body>
- <div id="wrap">
- <div id="main">
- <div>
- <input type="button" onclick="getPictureByCameraCustomCrop()" value="拍照+裁剪" /><br><br>
- <input type="button" onclick="getPictureByCamera()" value="拍照+不裁剪" /><br><br>
- </div>
- <div>
- <input type="button" onclick="getPictureByAlbumCustomCrop()" value="从相册选择+裁剪" /><br><br>
- <input type="button" onclick="getPictureByAlbum()" value="从相册选择+不裁剪" /><br><br>
- </div>
- </div>
- </div>
- </body>
- <script type="text/javascript">
- var mtaTrack;
- apiready = function(){
- yolanda = api.require('yolanda');
- };
- function getPictureByCameraCustomCrop(){
- yolanda.getPicture({
- sourceType:'camera',
- isCustomCrop:true,
- maxSizeKB:120,
- scaleX:10,
- scaleY:7
- }, function(ret, err){
- if(ret.success){
- yolanda.cropImage({
- filepath:ret.filepath
- },function(ret,err){
- if(ret.success){
- alert(ret.msg+'\n文件路径:'+ret.filepath+'\n文件大小:'+ret.size+'KB');
- }else{
- alert(ret.msg);
- }
- });
- }else{
- alert(ret.msg);
- }
- });
- }
- function getPictureByCamera(){
- yolanda.getPicture({
- sourceType:'camera',
- isCustomCrop:false,
- maxSizeKB:120,
- scaleX:10,
- scaleY:7
- }, function(ret, err){
- if(ret.success){
- alert(ret.msg+'\n文件路径:'+ret.filepath+'\n文件大小:'+ret.size+'KB');
- }else{
- alert(ret.msg);
- }
- });
- }
- function getPictureByAlbumCustomCrop(){
- yolanda.getPicture({
- sourceType:'album',
- isCustomCrop:true,
- maxSizeKB:120,
- scaleX:10,
- scaleY:7
- }, function(ret, err){
- if(ret.success){
- yolanda.cropImage({
- filepath:ret.filepath
- },function(ret,err){
- if(ret.success){
- alert(ret.msg+'\n文件路径:'+ret.filepath+'\n文件大小:'+ret.size+'KB');
- }else{
- alert(ret.msg);
- }
- });
- }else{
- alert(ret.msg);
- }
- });
- }
- function getPictureByAlbum(){
- yolanda.getPicture({
- sourceType:'album',
- isCustomCrop:false,
- maxSizeKB:120,
- scaleX:10,
- scaleY:7
- }, function(ret, err){
- if(ret.success){
- alert(ret.msg+'\n文件路径:'+ret.filepath+'\n文件大小:'+ret.size+'KB');
- }else{
- alert(ret.msg);
- }
- });
- }
- </script>
- </html>
复制代码
|
本帖子中包含更多资源,您需要 登录 才可以下载或查看,没有帐号?立即注册
X
|