Merge pull request #3277 from dreampiggy/fix_pixel_ratio_thumbnail_calculation
Fix pixel ratio thumbnail calculation
This commit is contained in:
commit
e0b8bf97d0
|
@ -35,8 +35,8 @@
|
|||
NSImageRep *imageRep = [self bestRepresentationForRect:imageRect context:nil hints:nil];
|
||||
CGFloat width = imageRep.size.width;
|
||||
CGFloat height = imageRep.size.height;
|
||||
NSUInteger pixelWidth = imageRep.pixelsWide;
|
||||
NSUInteger pixelHeight = imageRep.pixelsHigh;
|
||||
CGFloat pixelWidth = (CGFloat)imageRep.pixelsWide;
|
||||
CGFloat pixelHeight = (CGFloat)imageRep.pixelsHigh;
|
||||
if (width > 0 && height > 0) {
|
||||
CGFloat widthScale = pixelWidth / width;
|
||||
CGFloat heightScale = pixelHeight / height;
|
||||
|
|
|
@ -191,8 +191,8 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination
|
|||
// Some options need to pass to `CGImageSourceCopyPropertiesAtIndex` before `CGImageSourceCreateImageAtIndex`, or ImageIO will ignore them because they parse once :)
|
||||
// Parse the image properties
|
||||
NSDictionary *properties = (__bridge_transfer NSDictionary *)CGImageSourceCopyPropertiesAtIndex(source, index, (__bridge CFDictionaryRef)options);
|
||||
NSUInteger pixelWidth = [properties[(__bridge NSString *)kCGImagePropertyPixelWidth] unsignedIntegerValue];
|
||||
NSUInteger pixelHeight = [properties[(__bridge NSString *)kCGImagePropertyPixelHeight] unsignedIntegerValue];
|
||||
CGFloat pixelWidth = [properties[(__bridge NSString *)kCGImagePropertyPixelWidth] doubleValue];
|
||||
CGFloat pixelHeight = [properties[(__bridge NSString *)kCGImagePropertyPixelHeight] doubleValue];
|
||||
CGImagePropertyOrientation exifOrientation = (CGImagePropertyOrientation)[properties[(__bridge NSString *)kCGImagePropertyOrientation] unsignedIntegerValue];
|
||||
if (!exifOrientation) {
|
||||
exifOrientation = kCGImagePropertyOrientationUp;
|
||||
|
@ -503,8 +503,8 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination
|
|||
maxPixelSize = maxPixelSizeValue.CGSizeValue;
|
||||
#endif
|
||||
}
|
||||
NSUInteger pixelWidth = CGImageGetWidth(imageRef);
|
||||
NSUInteger pixelHeight = CGImageGetHeight(imageRef);
|
||||
CGFloat pixelWidth = (CGFloat)CGImageGetWidth(imageRef);
|
||||
CGFloat pixelHeight = (CGFloat)CGImageGetHeight(imageRef);
|
||||
CGFloat finalPixelSize = 0;
|
||||
if (maxPixelSize.width > 0 && maxPixelSize.height > 0 && pixelWidth > maxPixelSize.width && pixelHeight > maxPixelSize.height) {
|
||||
CGFloat pixelRatio = pixelWidth / pixelHeight;
|
||||
|
|
|
@ -250,8 +250,8 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination
|
|||
maxPixelSize = maxPixelSizeValue.CGSizeValue;
|
||||
#endif
|
||||
}
|
||||
NSUInteger pixelWidth = CGImageGetWidth(imageRef);
|
||||
NSUInteger pixelHeight = CGImageGetHeight(imageRef);
|
||||
CGFloat pixelWidth = (CGFloat)CGImageGetWidth(imageRef);
|
||||
CGFloat pixelHeight = (CGFloat)CGImageGetHeight(imageRef);
|
||||
if (maxPixelSize.width > 0 && maxPixelSize.height > 0 && pixelWidth > maxPixelSize.width && pixelHeight > maxPixelSize.height) {
|
||||
CGFloat pixelRatio = pixelWidth / pixelHeight;
|
||||
CGFloat maxPixelSizeRatio = maxPixelSize.width / maxPixelSize.height;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#import "SDWebImageError.h"
|
||||
#import "SDInternalMacros.h"
|
||||
#import "SDWebImageTransitionInternal.h"
|
||||
#import "SDImageCache.h"
|
||||
|
||||
const int64_t SDWebImageProgressUnitCountUnknown = 1LL;
|
||||
|
||||
|
|
Loading…
Reference in New Issue