What is the best way to get the size (width and height) of an NSBitmapImageRep?
This is what I'm doing now:
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;
Seems like an awful lot of typing for something that should be as easy as [bitmap getWidth]...
I've seen some posts on the internet that query the size like this (this is not in the documentation):
NSSize imageSize = [bitmap size];
But the values don't seem to represent the pixel dimensions of the image (for example, I get a float value of 122.869835 instead of 256, which is the real pixel width of the image).