影像采集-拍照 (用自己的插件 )簡單邏輯
阿新 • • 發佈:2018-07-20
random spl 客戶 edit 點擊 asc chan bytes wid
6 使用(把圖片上傳服務器,再把圖片信息保存到表裏 如task_img 及img_info),再把顯示圖片的地址改成服務器的地址顯示
a.二進制上傳圖片:
1. 加載插件 camera.js 加載的插件是攝像頭插件 image.js 加載的是圖像插件 ??????????????? 2.把插件的el 加載到要插入的dom元素中, 一般用 embed 標簽可設置器寬高 3.在調用攝像頭插件 that.cameraPlugin.open()方法打開插件 4.調用圖像插件 that.cameraPlugin.capture() 截圖 並且會把當前截圖的路徑返回 5.調用圖像插件 顯示圖片 that.imgEditerPlugin.showImage(URL, 0, that.width, that.height);????????????
var dataURItoBlob = function (dataURI) { var byteString = atob(dataURI.split(‘,‘)[1]); var mimeString = dataURI.split(‘,‘)[0].split(‘:‘)[1].split(‘;‘)[0]; ???? var ab = new ArrayBuffer(byteString.length); var ia = new Uint8Array(ab); for (var i = 0; i < byteString.length; i++) { ia[i] = byteString.charCodeAt(i); } return new Blob([ab], {type: mimeString}); }, fd = new FormData(), fname = (new Date().getTime()) + parseInt(Math.random() * 1000, 10) + ".jpg", blob = dataURItoBlob("data:image/jpg;base64," + that.imgEditerPlugin.encodeBase64()); fd.append("file", blob, fname); ajax.ajax({ contentType: false, cache: false, url: uploadUrl, type: "POST", processData: false, data: fd }).then(function (result) {});
7.圖片共享:
a.先根據客戶號、影像類別查找已經已經上傳的圖片幀、先獲取到以前的url並顯示圖片;
b.點擊使用的時候,服務端拷貝一份相同的圖片,並且保存數據到表裏,再返回對應當前幀的服務器圖片地址,替換對應幀記錄顯示。
影像采集-拍照 (用自己的插件 )簡單邏輯