How to get resolution of an NSImage or NSBitmapImageRep?
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.
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
NSSize s = [rep size];
float wRes = 72.0 * [rep pixelsWide] / s.width;
float hRes = 72.0 * [rep pixelsHigh] / s.height;
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
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!
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| DPI and Resolution for Graphics | mickyg | 9 | 6,664 |
Apr 27, 2012 03:02 PM Last Post: Andres Calil |
|
| Strange OpenGl or NSBitmapImageRep error | magnusrw | 4 | 2,812 |
Apr 24, 2009 11:13 AM Last Post: magnusrw |
|
| Basic NSImage drawing help please! | xenocide | 6 | 4,798 |
Feb 2, 2009 11:01 AM Last Post: FlamingHairball |
|
| NSImage and PNG's | bmantzey | 3 | 4,350 |
Nov 29, 2008 07:01 PM Last Post: arekkusu |
|
| NSBitmapImageRep/CIImage questions | Caveman | 6 | 5,084 |
Sep 6, 2008 04:37 PM Last Post: ThemsAllTook |
|

