IOS 照相問題

來源:互聯網
上載者:User

標籤:idt   jpg   open   ima   one   new   toast   路徑   turn   

在iphone上時而出問題時而正常。反覆測試後發現問題出在使用iphone網路攝影機拍攝的照片,這些照片尺寸是3264x2448,但是其實照片的尺寸是2448x3264,寬和高正好是相反的,後來我把照片導到電腦裡,的確尺寸應該是2448x3264。原因是iPhone拍攝的圖片的起始點是螢幕的左下角,所以寬和高是相反的。。

以下是通過mui 拍照功能、裁剪圖片上傳判斷。

//拍照操作function getImage() {plus.camera.getCamera().captureImage(function(path) {plus.io.resolveLocalFileSystemURL(path, function(entry) {var path = entry.toLocalURL();var filename = entry.name;goShowImg(path, filename,1);}, function(e) {plus.nativeUI.toast("讀取拍照檔案錯誤:" + e.message);});}, function(e) {}, {filename: "_doc/camera/",index: 1});}// 相簿選取function galleryImg() {plus.gallery.pick(function(path) {var filename = ‘images.jpg‘;//alert(‘路徑:‘ + path);goShowImg(path, filename,0);}, function(e) {console.log("取消選擇圖片");}, {filter: "image"});}

  

//跳轉到裁剪頁面function goShowImg(path, filename,camera) {//alert(‘我要跳轉了‘);console.log(‘camera: ‘ + camera)var image = new Image();image.src = path;mui.openWindow({url: ‘clip_img.html‘,id: ‘clip_img.html‘,extras: {path: path,filename: filename,idName: ‘goods_add.html‘,camera: camera},show: {autoShow: false}});}

  

 // 獲得圖片和螢幕的寬度,以及比例var imgtemp = new Image();imgtemp.src = img.src;var imgWidth;var imgHeight;var proportion;var displayWidth = plus.display.resolutionWidth;var system = plus.os.name;if(system !== ‘Android‘ && parseInt(camera)==1){imgWidth = imgtemp.width;imgHeight = imgtemp.height;proportion= getProportion(imgHeight, displayWidth);}else{imgWidth = imgtemp.width;imgHeight = img.height;proportion = getProportion(imgWidth, displayWidth);}

  

img.setAttribute("width", plus.display.resolutionWidth);

// 計算圖片和顯示屏的比例 function getProportion(imgW, displayW) { return imgW / displayW; }

  

IOS 照相問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.