图片上传 (本地与相机)
发布于 2年前 作者 yf0311 1767 次浏览 来自 分享

base64-encoded image

从相机获取照片

$scope.getCamera = () ->
  options = 
    quality: 50
    destinationType: Camera.DestinationType.DATA_URL
    sourceType: Camera.PictureSourceType.CAMERA
    allowEdit: true
    encodingType: Camera.EncodingType.JPEG
    targetWidth: 100
    targetHeight: 100
    popoverOptions: CameraPopoverOptions
    saveToPhotoAlbum: false 
  $cordovaCamera.getPicture(options).then (imageData) ->
    image = document.getElementById('myImage')
    image.src = 'data:image/jpeg;base64,' + imageData
    $scope.image_lists = imageData
    return

本地上传图片

$scope.getCapture = ->
  options =
    quality: 30
    targetWidth: 300
    targetHeight: 300
    correctOrientation: true
    destinationType: navigator.camera.DestinationType.DATA_URL
    sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
  $cordovaCamera.getPicture(options).then (imageData) ->
    $scope.param = imageData
  return
1 回复

很棒,谢谢

回到顶部