mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-03 21:16:35 +00:00
parent
7fa5aa5e01
commit
59c9fc8819
@ -175,11 +175,19 @@
|
|||||||
|
|
||||||
ASDisplayNodeAssert(parameters.contentsScale > 0, @"invalid contentsScale at display time");
|
ASDisplayNodeAssert(parameters.contentsScale > 0, @"invalid contentsScale at display time");
|
||||||
|
|
||||||
|
// if the image is resizable, bail early since the image has likely already been configured
|
||||||
|
BOOL stretchable = !UIEdgeInsetsEqualToEdgeInsets(image.capInsets, UIEdgeInsetsZero);
|
||||||
|
if (stretchable) {
|
||||||
|
if (parameters.imageModificationBlock != NULL) {
|
||||||
|
image = parameters.imageModificationBlock(image);
|
||||||
|
}
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
CGRect bounds = parameters.bounds;
|
CGRect bounds = parameters.bounds;
|
||||||
|
|
||||||
CGFloat contentsScale = parameters.contentsScale;
|
CGFloat contentsScale = parameters.contentsScale;
|
||||||
UIViewContentMode contentMode = parameters.contentMode;
|
UIViewContentMode contentMode = parameters.contentMode;
|
||||||
BOOL stretchable = !UIEdgeInsetsEqualToEdgeInsets(image.capInsets, UIEdgeInsetsZero);
|
|
||||||
CGSize imageSize = image.size;
|
CGSize imageSize = image.size;
|
||||||
CGSize imageSizeInPixels = CGSizeMake(imageSize.width * image.scale, imageSize.height * image.scale);
|
CGSize imageSizeInPixels = CGSizeMake(imageSize.width * image.scale, imageSize.height * image.scale);
|
||||||
CGSize boundsSizeInPixels = CGSizeMake(floorf(bounds.size.width * contentsScale), floorf(bounds.size.height * contentsScale));
|
CGSize boundsSizeInPixels = CGSizeMake(floorf(bounds.size.width * contentsScale), floorf(bounds.size.height * contentsScale));
|
||||||
@ -245,10 +253,6 @@
|
|||||||
result = parameters.imageModificationBlock(result);
|
result = parameters.imageModificationBlock(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stretchable) {
|
|
||||||
return [result resizableImageWithCapInsets:image.capInsets resizingMode:image.resizingMode];
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,6 +384,12 @@ extern asimagenode_modification_block_t ASImageNodeTintColorModificationBlock(UI
|
|||||||
|
|
||||||
UIImage *modifiedImage = UIGraphicsGetImageFromCurrentImageContext();
|
UIImage *modifiedImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||||
UIGraphicsEndImageContext();
|
UIGraphicsEndImageContext();
|
||||||
|
|
||||||
|
// if the original image was stretchy, keep it stretchy
|
||||||
|
if (!UIEdgeInsetsEqualToEdgeInsets(originalImage.capInsets, UIEdgeInsetsZero)) {
|
||||||
|
modifiedImage = [modifiedImage resizableImageWithCapInsets:originalImage.capInsets resizingMode:originalImage.resizingMode];
|
||||||
|
}
|
||||||
|
|
||||||
return modifiedImage;
|
return modifiedImage;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user