我不知道用户是否有办法将椭圆形的图像剪掉,但我一定会告诉你,你可以根据你的适应情况用 CSS 修改。
从相册中获取图片
$scope.getPicture = function() {
var options = {
quality: 50,
targetWidth: 512,
targetHeight: 512,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
encodingType: Camera.EncodingType.JPEG,
correctOrientation: true,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false
};
$cordovaCamera.getPicture(options).then(function(imageData) {
$scope.photo = "data:image/jpeg;base64," + imageData;
}, function(err) {
// An error occured. Show a message to the user
});
从相机设备拍照
$scope.takePicture = function() {
var options = {
quality: 50,
targetWidth: 512,
targetHeight: 512,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
encodingType: Camera.EncodingType.JPEG,
correctOrientation: true,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false,
};
$cordovaCamera.getPicture(options).then(function(imageData) {
$scope.photo = "data:image/jpeg;base64," + imageData;
}, function(err) {
// An error occured. Show a message to the user
});
}
从表格到图片的例子
<div style="background: url({{photo}}); background-size: cover;background-position: center;height:210px;">
这个小圆形图片的例子,不过你可以随意修改成这个。