adium-1.3 398:4c0dd30c3b93: Fix creating smaller JPGs for AIM/IC...

commits at adium.im commits at adium.im
Tue Jan 12 02:55:36 UTC 2010


details:	http://hg.adium.im/adium-1.3/rev/4c0dd30c3b93
revision:	398:4c0dd30c3b93
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.
(transplanted from 62a90e20d6cc55a98ec787ebd21e7162f48482bf)

diffs (45 lines):

diff -r e83cbdce7b64 -r 4c0dd30c3b93 Frameworks/AIUtilities Framework/Source/AIImageAdditions.m
--- a/Frameworks/AIUtilities Framework/Source/AIImageAdditions.m	Mon Jan 11 21:26:34 2010 -0500
+++ 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