[英]How to crop the gallery images in appcelerator?
I am developing iOS application. 我正在开发iOS应用程序。 In that I have a requirement to crop the images while uploading the images from gallery.can any one help me how to crop the images in appcelerator for ios platform. 我需要在从图库上载图像时裁剪图像。任何人都可以帮助我如何在iOS平台的appcelerator中裁剪图像。
Thanks in advance 提前致谢
You can use the internal blob.imageAsCrop() method: 您可以使用内部的blob.imageAsCrop()方法:
https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Blob-method-imageAsCropped https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Blob-method-imageAsCropped
Properties are width, height, x, y ( https://docs.appcelerator.com/platform/latest/#!/api/ImageAsCroppedDict ) 属性是宽度,高度,x,y( https://docs.appcelerator.com/platform/latest/#!/api/ImageAsCroppedDict )
It'll returns another blob which you can save or display again 它将返回另一个Blob,您可以将其保存或再次显示
Example: 例:
var croppedImage = blob.imageAsCropped({x : 20, y : 20, width : 100, height : 100});
var imageView = Titanium.UI.createImageView({
image:croppedImage,
width: 100, height:100
});
Example 2: 范例2:
Titanium.Media.openPhotoGallery({
success: function(event) {
var galleryImage = event.media;
var dict = {
x: 0,
y: 50,
width: 300,
height: 300
};
var croppedImage = galleryImage.imageAsCropped(dict);
var imageView = Ti.UI.createImageView({
image: croppedImage,
height: 'auto',
width: 'auto'
});
$.index.add(imageView);
},
cancel: function() {},
savedToPhotoGallery: true,
allowEditing: true,
mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],
showControls: true
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.