diff options
Diffstat (limited to 'AppKit/GTMNSImage+Scaling.m')
-rw-r--r-- | AppKit/GTMNSImage+Scaling.m | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/AppKit/GTMNSImage+Scaling.m b/AppKit/GTMNSImage+Scaling.m index 57687fd..5f31190 100644 --- a/AppKit/GTMNSImage+Scaling.m +++ b/AppKit/GTMNSImage+Scaling.m @@ -23,6 +23,9 @@ @implementation NSImage (GTMNSImageScaling) +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6 +// If you are on SnowLeopard use +// -[NSImage bestRepresentationForRect:context:hints:] - (NSImageRep *)gtm_bestRepresentationForSize:(NSSize)size { NSImageRep *bestRep = [self gtm_representationOfSize:size]; if (bestRep) { @@ -37,7 +40,7 @@ while ((thisRep = [repEnum nextObject])) { CGFloat thisDistance; thisDistance = MIN(size.width - [thisRep size].width, - size.height-[thisRep size].height); + size.height - [thisRep size].height); if (repDistance < 0 && thisDistance > 0) continue; if (ABS(thisDistance) < ABS(repDistance) @@ -53,6 +56,7 @@ return bestRep; } +#endif // MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6 - (NSImageRep *)gtm_representationOfSize:(NSSize)size { NSArray *reps = [self representations]; @@ -80,8 +84,15 @@ return NO; } - NSBitmapImageRep *bestRep = - (NSBitmapImageRep *)[self gtm_bestRepresentationForSize:size]; + NSBitmapImageRep *bestRep; +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6 + bestRep = (NSBitmapImageRep *)[self gtm_bestRepresentationForSize:size]; +#else + bestRep + = (NSBitmapImageRep *)[self bestRepresentationForRect:GTMNSRectOfSize(size) + context:nil + hints:nil]; +#endif // MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6 NSRect drawRect = GTMNSScaleRectToRect(GTMNSRectOfSize([bestRep size]), GTMNSRectOfSize(size), |