Adium

Changeset 21554

Show
Ignore:
Timestamp:
11/06/2007 03:12:45 PM (1 year ago)
Author:
boredzo
Message:

As of Mac OS X 10.5.0, drawing certain images into a smaller image results in a cached image rep being created at the destination image's size, rather than the source image's size, and the source image's original rep being thrown away. When we later went to draw the image at full size, the image was scaled up, resulting in a blocky mess.

The fix is simply to make a copy of the image using -copy and draw the copy. Lame, but it works, and it fixes #8181.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/adium-1.1/Frameworks/AIUtilities Framework/Source/AIImageAdditions.m

    r19866 r21554  
    212212                        } 
    213213                } 
    214                  
     214 
     215                NSImage *imageToDraw = [self copy]; 
     216 
    215217                newRect = NSMakeRect(0,0,size.width,size.height); 
    216218                newImage = [[NSImage alloc] initWithSize:size]; 
     
    220222                NSImageRep      *bestRep; 
    221223                if (allowAnimation && 
    222                         (bestRep = [self bestRepresentationForDevice:nil]) && 
     224                        (bestRep = [imageToDraw bestRepresentationForDevice:nil]) && 
    223225                        [bestRep isKindOfClass:[NSBitmapImageRep class]] &&  
    224226                        (delta == 1.0) && 
     
    231233                        //Highest quality interpolation 
    232234                        [[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh]; 
    233                         [self drawInRect:newRect 
    234                                        fromRect:NSMakeRect(0,0,originalSize.width,originalSize.height) 
    235                                   operation:NSCompositeCopy 
    236                                        fraction:delta]; 
     235                        [imageToDraw drawInRect:newRect 
     236                                       fromRect:NSMakeRect(0,0,originalSize.width,originalSize.height) 
     237                                      operation:NSCompositeCopy 
     238                                       fraction:delta]; 
    237239                         
    238240                        [newImage unlockFocus]; 
    239241                } 
     242 
     243                [imageToDraw release]; 
    240244 
    241245                return [newImage autorelease]; 
  • trunk/Frameworks/AIUtilities Framework/Source/AIImageAdditions.m

    r21539 r21554  
    232232                        } 
    233233                } 
    234                  
     234 
     235                NSImage *imageToDraw = [self copy]; 
     236 
    235237                newRect = NSMakeRect(0,0,size.width,size.height); 
    236238                newImage = [[NSImage alloc] initWithSize:size]; 
     
    240242                NSImageRep      *bestRep; 
    241243                if (allowAnimation && 
    242                         (bestRep = [self bestRepresentationForDevice:nil]) && 
     244                        (bestRep = [imageToDraw bestRepresentationForDevice:nil]) && 
    243245                        [bestRep isKindOfClass:[NSBitmapImageRep class]] &&  
    244246                        (delta == 1.0) && 
     
    251253                        //Highest quality interpolation 
    252254                        [[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh]; 
    253                         [self drawInRect:newRect 
    254                                        fromRect:NSMakeRect(0,0,originalSize.width,originalSize.height) 
    255                                   operation:NSCompositeCopy 
    256                                        fraction:delta]; 
     255                        [imageToDraw drawInRect:newRect 
     256                                       fromRect:NSMakeRect(0,0,originalSize.width,originalSize.height) 
     257                                      operation:NSCompositeCopy 
     258                                       fraction:delta]; 
    257259                         
    258260                        [newImage unlockFocus]; 
    259261                } 
     262 
     263                [imageToDraw release]; 
    260264 
    261265                return [newImage autorelease];