iDevGames Forums

Full Version: How to get resolution of an NSImage or NSBitmapImageRep?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I can obtain the size (pixel dimensions) of an NSImage or NSImageBitmapImageRep, but because NSImage does odd stuff adjusting the size to fit the DPI when it's loaded then if a texture has a non-standard DPI my OpenGL texture code an choke on the resulting non-power-of-two pixel dimensions.

I'd just like to be able to reject files that aren't 72dpi x 72dpi, but can't see a way to do it.

Any help (ideally in Cocoa/Obj-C) would be very appreciated.
Don't use NSBitmapImageRep to load textures? There's a perfectly good QuickTime API for that that is actually usable for the purpose Smile
NSSize s = [rep size];
float wRes = 72.0 * [rep pixelsWide] / s.width;
float hRes = 72.0 * [rep pixelsHigh] / s.height;
OneSadCookie Wrote:Don't use NSBitmapImageRep to load textures? There's a perfectly good QuickTime API for that that is actually usable for the purpose Smile

Unfortunately I don't want to use QuickTime in Oolite since its methods can't easily be crossed to Linux.
willThimbleby Wrote:NSSize s = [rep size];
float wRes = 72.0 * s.width / [rep pixelsWide];
float hRes = 72.0 * s.height / [rep pixelsHigh];

Thanks - that tells me everything I need! Smile
Reference URL's