mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat(image-asset-ios): add autoScaleFactor option to switch auto scaling (#6127)
This commit is contained in:
committed by
GitHub
parent
7e89f942b4
commit
81e63ee19e
@@ -50,7 +50,7 @@ export class ImageAsset extends common.ImageAsset {
|
||||
let imageRequestOptions = PHImageRequestOptions.alloc().init();
|
||||
imageRequestOptions.deliveryMode = PHImageRequestOptionsDeliveryMode.HighQualityFormat;
|
||||
imageRequestOptions.networkAccessAllowed = true;
|
||||
|
||||
|
||||
PHImageManager.defaultManager().requestImageForAssetTargetSizeContentModeOptionsResultHandler(this.ios, requestedSize, PHImageContentMode.AspectFit, imageRequestOptions,
|
||||
(image, imageResultInfo) => {
|
||||
if (image) {
|
||||
@@ -64,8 +64,11 @@ export class ImageAsset extends common.ImageAsset {
|
||||
);
|
||||
}
|
||||
|
||||
private scaleImage(image: UIImage, requestedSize: {width: number, height: number}): UIImage {
|
||||
UIGraphicsBeginImageContextWithOptions(requestedSize, false, 0.0);
|
||||
private scaleImage(image: UIImage, requestedSize: { width: number, height: number }): UIImage {
|
||||
// scaleFactor = 0 takes the scale factor of the devices's main screen.
|
||||
const scaleFactor = this.options && this.options.autoScaleFactor === false ? 1.0 : 0.0;
|
||||
|
||||
UIGraphicsBeginImageContextWithOptions(requestedSize, false, scaleFactor);
|
||||
image.drawInRect(CGRectMake(0, 0, requestedSize.width, requestedSize.height));
|
||||
let resultImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
|
||||
Reference in New Issue
Block a user