adium 2806:5585035f872b: Fix creating smaller JPGs for AIM/ICQ b...

commits at adium.im commits at adium.im
Thu Oct 29 15:48:00 UTC 2009


details:	http://hg.adium.im/adium/rev/5585035f872b
revision:	2806:5585035f872b
author:		Zachary West <zacw at adium.im>
date:		Thu Oct 29 11:44:17 2009 -0400

Fix creating smaller JPGs for AIM/ICQ buddy icons. Fixes #12982.

In Snow Leopard, drawing an image copies in the main display's color profile, which bloats the image's size. Nullify the color profile in the image we're creating so that the JPG representation won't also have it.

diffs (45 lines):

diff -r 9b757472094b -r 5585035f872b Frameworks/AIUtilities Framework/Source/AIImageAdditions.m
--- a/Frameworks/AIUtilities Framework/Source/AIImageAdditions.m	Wed Oct 28 21:04:52 2009 -0400
+++ b/Frameworks/AIUtilities Framework/Source/AIImageAdditions.m	Thu Oct 29 11:44:17 2009 -0400
@@ -53,10 +53,9 @@
 //Create and return an opaque bitmap image rep, replacing transparency with [NSColor whiteColor]
 - (NSBitmapImageRep *)opaqueBitmapImageRep
 {
-	NSImage			*tempImage;
-	NSEnumerator	*enumerator;
-	NSImageRep		*imageRep;
-	NSSize			size = [self size];
+	NSImage				*tempImage = nil;
+	NSBitmapImageRep	*imageRep = nil;
+	NSSize				size = [self size];
 	
 	//Work with a temporary image so we don't modify self
 	tempImage = [[[NSImage allocWithZone:[self zone]] initWithSize:size] autorelease];
@@ -75,10 +74,10 @@
 	[tempImage unlockFocus];
 	
 	//Find an NSBitmapImageRep from the temporary image
-	enumerator = [[tempImage representations] objectEnumerator];
-	while ((imageRep = [enumerator nextObject])) {
-		if ([imageRep isKindOfClass:[NSBitmapImageRep class]])
-			break;
+	for (NSImageRep *rep in tempImage.representations) {
+		if ([rep isKindOfClass:[NSBitmapImageRep class]]) {
+			imageRep = (NSBitmapImageRep *)rep;
+		}
 	}
 	
 	//Make one if necessary
@@ -86,7 +85,11 @@
 		imageRep = [NSBitmapImageRep imageRepWithData:[tempImage TIFFRepresentation]];
     }
 	
-	return (NSBitmapImageRep *)imageRep;
+	// 10.6 behavior: Drawing into a new image copies the display's color profile in.
+	// Remove the color profile so we don't bloat the image size.
+	[imageRep setProperty:NSImageColorSyncProfileData withValue:nil];
+	
+	return imageRep;
 }
 
 - (NSBitmapImageRep *)largestBitmapImageRep




More information about the commits mailing list