2011-01-20 2 views
3

NSImage의 실제 너비와 높이를 어떻게 알 수 있습니까? 나는 72보다 높은 DPI 인 이미지가 NSImage.size 매개 변수를 통해 너비와 높이가 부정확하다는 것을 알게되었습니다.NSImage DPI 질문

내가 대안으로 사용할 수있는 그러나 bestRepresentationForDevice 10.6에 사용되지 않습니다
NSBitmapImageRep *rep = [image bestRepresentationForDevice: nil]; 

NSSize pixelSize = NSMakeSize([rep pixelsWide],[rep pixelsHigh]); 

이 ..., 문서가 다른 방법을 제공하지 않습니다

나는 Cocoadev에이 예제를 보았다?

답변

4

최대 -size와 하나 찾고 이미지의 표현을 통해 NSImage

NSBitmapImageRep* rep = [NSBitmapImageRep imageRepWithData:[image TIFFRepresentation]]; 
+0

작품! 좋아, 고마워. – mootymoots

0
@interface NSImage (Representation) 
-(NSBitmapImageRep*)bitmapRepresentation; 
@end 

@implementation NSImage (Representation) 
-(NSBitmapImageRep*)bitmapRepresentation { 
    for (id thing in self.representations) { 
     if (![thing isKindOfClass:[NSBitmapImageRep class]]) continue; 
     return (NSBitmapImageRep*)thing; 
    } 
    return nil; 
} 
@end 
1

반복 처리의 TIFF 표현에서 NSBitmapImageRep를 구축 할 수 있습니다. -bestRepresentationForRect : context : hints : 매우 큰 직사각형을 먹일 경우이 작업을 수행해야합니다.