Tôi thấy rằng đôi khi kích thước NSImage không phải là kích thước thực (với một số hình ảnh) và kích thước CIImage luôn luôn là thực. Tôi đã thử nghiệm với điều này image.Kích thước NSImage không phải kích thước thật với một số hình ảnh?
Đây là mã nguồn mà tôi đã viết cho thử nghiệm:
NSImage *_imageNSImage = [[NSImage alloc]initWithContentsOfFile:@"<path to image>"];
NSSize _dimensions = [_imageNSImage size];
[_imageNSImage release];
NSLog(@"Width from CIImage: %f",_dimensions.width);
NSLog(@"Height from CIImage: %f",_dimensions.height);
NSURL *_myURL = [NSURL fileURLWithPath:@"<path to image>"];
CIImage *_imageCIImage = [CIImage imageWithContentsOfURL:_myURL];
NSRect _rectFromCIImage = [_imageCIImage extent];
NSLog(@"Width from CIImage: %f",_rectFromCIImage.size.width);
NSLog(@"Height from CIImage: %f",_rectFromCIImage.size.height);
Và đầu ra là:
Vì vậy, làm thế nào mà có thể ?? Có lẽ tôi đang làm gì đó sai?
Cảm ơn bạn về Hình nền tuyệt vời! – JustSid
@JustSid Bạn được chào đón :) –