2009-03-20 3 views
1

NSBitmapImageRepのサイズ(幅と高さ)を取得する最適な方法は何ですか?ピクセルサイズod NSBitmapImageRep

これは私が今やっていることです:

NSBitmapImageRep *bitmap; 

NSInteger samplesPerPixel = [bitmap samplesPerPixel]; 
NSInteger bytesPerPlane = [bitmap bytesPerPlane]; 
NSInteger bytesPerRow = [bitmap bytesPerRow]; 
NSInteger numberOfPlanes = [bitmap numberOfPlanes]; 

NSUInteger numPixels = numberOfPlanes * bytesPerPlane/samplesPerPixel; 
NSUInteger width = bytesPerRow/samplesPerPixel; 
NSUInteger height = numPixels/width; 

は、私が見てきた[ビットマップのgetWidth] ...

ほど簡単であるべきものを入力しての非常に多くのように思えますこのようなサイズを照会し、インターネット上でいくつかの記事(これはドキュメントではありません):

NSSize imageSize = [bitmap size]; 

しかし、値は、たとえば、私はfloの取得(画像のピクセル寸法を表していないようです画像の実際のピクセル幅である256の代わりに122.869835の値)。

答えて

9
+0

@peter:あなたがこの情報を見つけましたか?私は見て、NSBitmapImageRepのドキュメントにはありません。 – lajos

+0

リンクをクリックすると、これらのメソッドはNSBitmapImageRepのスーパークラスNSImageRepにあります。 –

関連する問題