From f99dd68a9f2d27f620fe69e79c9c324865ce1805 Mon Sep 17 00:00:00 2001 From: Garrett Moon Date: Thu, 8 Mar 2018 16:21:54 -0800 Subject: [PATCH] [#trivial] fixes rendered image quality on networked image nodes which have their image directly set. (#826) --- Source/ASNetworkImageNode.h | 10 ++++++++-- Source/ASNetworkImageNode.mm | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Source/ASNetworkImageNode.h b/Source/ASNetworkImageNode.h index 4100b52209..ec97e8469e 100644 --- a/Source/ASNetworkImageNode.h +++ b/Source/ASNetworkImageNode.h @@ -120,13 +120,19 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, assign, readwrite) BOOL shouldRenderProgressImages; /** - * The image quality of the current image. This is a number between 0 and 1 and can be used to track + * The image quality of the current image. + * + * If the URL is set, this is a number between 0 and 1 and can be used to track * progressive progress. Calculated by dividing number of bytes / expected number of total bytes. + * This is zero until the first progressive render or the final display. + * + * If the URL is unset, this is 1 if defaultImage or image is set to non-nil. + * */ @property (nonatomic, assign, readonly) CGFloat currentImageQuality; /** - * The image quality (value between 0 and 1) of the last image that completed displaying. + * The currentImageQuality (value between 0 and 1) of the last image that completed displaying. */ @property (nonatomic, assign, readonly) CGFloat renderedImageQuality; diff --git a/Source/ASNetworkImageNode.mm b/Source/ASNetworkImageNode.mm index 4c600f0612..f7c430a466 100755 --- a/Source/ASNetworkImageNode.mm +++ b/Source/ASNetworkImageNode.mm @@ -141,6 +141,11 @@ [self _locked_cancelDownloadAndClearImageWithResumePossibility:NO]; } + // If our image is being set externally, the image quality is 100% + if (imageWasSetExternally) { + [self _setCurrentImageQuality:1.0]; + } + [self _locked__setImage:image]; } @@ -227,7 +232,6 @@ if (!_imageLoaded) { [self _setCurrentImageQuality:((_URL == nil) ? 0.0 : 1.0)]; [self _locked__setImage:defaultImage]; - } }