mirror of
https://github.com/HackPlan/AsyncDisplayKit.git
synced 2026-04-02 22:35:22 +08:00
1.6 KiB
1.6 KiB
title, layout, permalink, next
| title | layout | permalink | next |
|---|---|---|---|
| Image Scaling | docs | /docs/debug-tool-pixel-scaling.html | debug-tool-ASRangeController.html |
##Visualize ASImageNode.image’s pixel scaling## This debug feature adds a red text overlay on the bottom right hand corner of an ASImageNode if (and only if) the image’s size in pixels does not match it’s bounds size in pixels, e.g.
imageSizeInPixels = image.size * image.scale
boundsSizeInPixels = bounds.size * contentsScale
scaleFactor = imageSizeInPixels / boundsSizeInPixels
if (scaleFactor != 1.0) {
NSString *scaleString = [NSString stringWithFormat:@"%.2fx", scaleFactor];
_debugLabelNode.hidden = NO;
}
This debug feature is useful for quickly determining if you are
- downloading and rendering excessive amounts of image data
- upscaling a low quality image
In the screenshot below of an app with this debug feature enabled, you can see that the avatar image is unnecessarily large (9x too large) for it’s bounds size and that the center picture is more optimized, but not perfectly so. If you control your own endpoint, optimize your API / app to return an optimally sized image.
##Usage##
In your AppDelegate.m file,
- import `AsyncDisplayKit+Debug.h`
- add `[ASImageNode setShouldShowImageScalingOverlay:YES]` at the top of your `didFinishLaunchingWithOptions:` method