Merge pull request #2608 from zhongwuzw/fix_decompression_calculation
Fix wrong decompression scale calculation
This commit is contained in:
commit
7567f74e1f
|
@ -267,14 +267,14 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
|
||||||
CGSize sourceResolution = CGSizeZero;
|
CGSize sourceResolution = CGSizeZero;
|
||||||
sourceResolution.width = CGImageGetWidth(sourceImageRef);
|
sourceResolution.width = CGImageGetWidth(sourceImageRef);
|
||||||
sourceResolution.height = CGImageGetHeight(sourceImageRef);
|
sourceResolution.height = CGImageGetHeight(sourceImageRef);
|
||||||
float sourceTotalPixels = sourceResolution.width * sourceResolution.height;
|
CGFloat sourceTotalPixels = sourceResolution.width * sourceResolution.height;
|
||||||
// Determine the scale ratio to apply to the input image
|
// Determine the scale ratio to apply to the input image
|
||||||
// that results in an output image of the defined size.
|
// that results in an output image of the defined size.
|
||||||
// see kDestImageSizeMB, and how it relates to destTotalPixels.
|
// see kDestImageSizeMB, and how it relates to destTotalPixels.
|
||||||
float imageScale = kDestTotalPixels / sourceTotalPixels;
|
CGFloat imageScale = sqrt(kDestTotalPixels / sourceTotalPixels);
|
||||||
CGSize destResolution = CGSizeZero;
|
CGSize destResolution = CGSizeZero;
|
||||||
destResolution.width = (int)(sourceResolution.width*imageScale);
|
destResolution.width = (int)(sourceResolution.width * imageScale);
|
||||||
destResolution.height = (int)(sourceResolution.height*imageScale);
|
destResolution.height = (int)(sourceResolution.height * imageScale);
|
||||||
|
|
||||||
// device color space
|
// device color space
|
||||||
CGColorSpaceRef colorspaceRef = SDCGColorSpaceGetDeviceRGB();
|
CGColorSpaceRef colorspaceRef = SDCGColorSpaceGetDeviceRGB();
|
||||||
|
|
Loading…
Reference in New Issue