mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
Merge pull request #2843 from NativeScript/nnikolov/ImageAssetChangesForIos
Fixed issue when asset is created with native UIImage.
This commit is contained in:
@ -15,17 +15,22 @@ export class ImageAsset extends common.ImageAsset {
|
|||||||
|
|
||||||
public getImageAsync(callback: (image, error) => void) {
|
public getImageAsync(callback: (image, error) => void) {
|
||||||
let requestedSize = common.getRequestedImageSize({
|
let requestedSize = common.getRequestedImageSize({
|
||||||
width: this.ios.pixelWidth,
|
width: this.nativeImage ? this.nativeImage.size.width : this.ios.pixelWidth,
|
||||||
height: this.ios.pixelHeight
|
height: this.nativeImage ? this.nativeImage.size.height : this.ios.pixelHeight
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.nativeImage) {
|
||||||
|
let newSize = CGSizeMake(requestedSize.width, requestedSize.height);
|
||||||
|
UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0);
|
||||||
|
this.nativeImage.drawInRect(CGRectMake(0, 0, newSize.width, newSize.height));
|
||||||
|
let resizedImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||||
|
UIGraphicsEndImageContext();
|
||||||
|
callback(resizedImage, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let imageRequestOptions = PHImageRequestOptions.alloc().init();
|
let imageRequestOptions = PHImageRequestOptions.alloc().init();
|
||||||
imageRequestOptions.deliveryMode = PHImageRequestOptionsDeliveryMode.HighQualityFormat;
|
imageRequestOptions.deliveryMode = PHImageRequestOptionsDeliveryMode.HighQualityFormat;
|
||||||
|
|
||||||
if (this.nativeImage) {
|
|
||||||
callback(this.nativeImage, null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PHImageManager.defaultManager().requestImageForAssetTargetSizeContentModeOptionsResultHandler(this.ios, requestedSize, PHImageContentMode.AspectFit, imageRequestOptions,
|
PHImageManager.defaultManager().requestImageForAssetTargetSizeContentModeOptionsResultHandler(this.ios, requestedSize, PHImageContentMode.AspectFit, imageRequestOptions,
|
||||||
(image, imageResultInfo) => {
|
(image, imageResultInfo) => {
|
||||||
|
Reference in New Issue
Block a user