YAY, it looks pretty and smooth. (The album art)
authorKent Sutherland <ksuther@ithinksw.com>
Thu, 12 Feb 2004 02:08:24 +0000 (02:08 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Thu, 12 Feb 2004 02:08:24 +0000 (02:08 +0000)
MainController.m
StatusWindowController.m

index 0f86024..0bc7085 100755 (executable)
 #import "StatusWindowController.h"
 #import "StatusItemHack.h"
 
+@interface NSImage (WeeAdditions)
+- (NSImage *)imageScaledSmoothlyToSize:(NSSize)scaledSize;
+@end
+
+@implementation NSImage (WeeAdditions)
+
+- (NSImage *)imageScaledSmoothlyToSize:(NSSize)scaledSize
+{
+    NSImage *newImage;
+    NSImageRep *rep = [self bestRepresentationForDevice:nil];
+    
+    newImage = [[NSImage alloc] initWithSize:scaledSize];
+    [newImage lockFocus];
+    {
+        [[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh];
+        [[NSGraphicsContext currentContext] setShouldAntialias:YES];
+        [rep drawInRect:NSMakeRect(3, 3, scaledSize.width - 6, scaledSize.height - 6)];
+    }
+    [newImage unlockFocus];
+    return [newImage autorelease];
+}
+
+@end
+
 @interface MainController(Private)
 - (ITMTRemote *)loadRemote;
 - (void)timerUpdate;
@@ -798,7 +822,6 @@ static MainController *sharedController;
     } else {
         title = NSLocalizedString(@"noSongPlaying", @"No song is playing.");
     }
-
     [statusWindowController showSongInfoWindowWithSource:source
                                                    title:title
                                                    album:album
@@ -806,7 +829,7 @@ static MainController *sharedController;
                                                     time:time
                                                    track:track
                                                   rating:rating
-                                                   image:art];
+                                                   image:[[[[NSImage alloc] initWithData:[art TIFFRepresentation]] autorelease] imageScaledSmoothlyToSize:NSMakeSize(110,110)]];
 }
 
 - (void)showUpcomingSongs
index 8d9ec8a..2020530 100755 (executable)
 #import <ITKit/ITSlideVerticallyWindowEffect.h>
 #import <ITKit/ITPivotWindowEffect.h>
 
-
 static StatusWindowController *sharedController;
 
-
 @implementation StatusWindowController
 
 
@@ -114,13 +112,7 @@ static StatusWindowController *sharedController;
     NSString *text  = title;
     
     if ( art != nil ) {
-       NSSize oldSize, newSize;
-       image = art;
-       [image setScalesWhenResized:YES];
-       oldSize = [image size];
-       if (oldSize.width > oldSize.height) newSize = NSMakeSize(110,oldSize.height * (110.0f / oldSize.width));
-       else newSize = NSMakeSize(oldSize.width * (110.0f / oldSize.height),110);
-       [image setSize:newSize];
+        image = art;
     } else if ( source == ITMTRemoteLibrarySource ) {
         image = [NSImage imageNamed:@"Library"];
     } else if ( source == ITMTRemoteCDSource ) {