当我把它放入UIImage后,图像的大小做一个NSLog时,它出现在预期的大小。当我尝试CGImageSource时,我得到的图像尺寸是我期望的两倍。这是我正在使用的代码:CFImageSource认为我的视网膜图像是它的实际大小的2倍
NSString *fullPath = [self fullPathForThumbnail];
NSURL *imageFileURL = [NSURL fileURLWithPath:fullPath];
CGImageSourceRef imageSource = CGImageSourceCreateWithURL((__bridge CFURLRef)imageFileURL, NULL);
if (imageSource == NULL) {
// Error loading image
return NO;
}
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO], (NSString *)kCGImageSourceShouldCache,
nil];
CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, (__bridge CFDictionaryRef)options);
CGSize originalSize;
if (imageProperties) {
NSNumber *width = (NSNumber *)CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelWidth);
NSNumber *height = (NSNumber *)CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelHeight);
originalSize = CGSizeMake(width.floatValue, height.floatValue);
CFRelease(imageProperties);
}
这只发生在视网膜图像;非视网膜图像似乎是正确的大小。
听起来像你是混合点vs像素。这些方法明确指出它们正在返回像素。按比例分割将为您提供像素,并且应该在视网膜和非视网膜显示屏上匹配。 – bobnoble
2x是什么意思?假设A.png是100x100,[email protected]是200x200。该计划报告什么? 200x200或400x400?如果它报告200x200我认为这是预期的行为。 – Yuji
我在这里有点困惑。可以说这种情况: – WolfLink