Fix the PDF image without thumbnailPixelSize will result huge bitmap size, now fixed into 72 DPI matching PDFKit
This commit is contained in:
parent
c4b8660bb3
commit
f91d35ef8d
|
@ -215,19 +215,8 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination
|
||||||
BOOL createFullImage = thumbnailSize.width == 0 || thumbnailSize.height == 0 || pixelWidth == 0 || pixelHeight == 0 || (pixelWidth <= thumbnailSize.width && pixelHeight <= thumbnailSize.height);
|
BOOL createFullImage = thumbnailSize.width == 0 || thumbnailSize.height == 0 || pixelWidth == 0 || pixelHeight == 0 || (pixelWidth <= thumbnailSize.width && pixelHeight <= thumbnailSize.height);
|
||||||
if (createFullImage) {
|
if (createFullImage) {
|
||||||
if (isVector) {
|
if (isVector) {
|
||||||
if (thumbnailSize.width == 0 || thumbnailSize.height == 0) {
|
// Use 72 DPI by default, matching Apple's PDFKit behavior
|
||||||
// Provide the default pixel count for vector images, simply just use the screen size
|
NSUInteger rasterizationDPI = 72;
|
||||||
#if SD_WATCH
|
|
||||||
thumbnailSize = WKInterfaceDevice.currentDevice.screenBounds.size;
|
|
||||||
#elif SD_UIKIT
|
|
||||||
thumbnailSize = UIScreen.mainScreen.bounds.size;
|
|
||||||
#elif SD_MAC
|
|
||||||
thumbnailSize = NSScreen.mainScreen.frame.size;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
CGFloat maxPixelSize = MAX(thumbnailSize.width, thumbnailSize.height);
|
|
||||||
NSUInteger DPIPerPixel = 2;
|
|
||||||
NSUInteger rasterizationDPI = maxPixelSize * DPIPerPixel;
|
|
||||||
decodingOptions[kSDCGImageSourceRasterizationDPI] = @(rasterizationDPI);
|
decodingOptions[kSDCGImageSourceRasterizationDPI] = @(rasterizationDPI);
|
||||||
}
|
}
|
||||||
imageRef = CGImageSourceCreateImageAtIndex(source, index, (__bridge CFDictionaryRef)[decodingOptions copy]);
|
imageRef = CGImageSourceCreateImageAtIndex(source, index, (__bridge CFDictionaryRef)[decodingOptions copy]);
|
||||||
|
|
Loading…
Reference in New Issue