Annotation of chimera/NSImageAdditions.m, revision 1.1

1.1     ! macserv     1: #import "NSImageAdditions.h"
        !             2: #import <Cocoa/Cocoa.h>
        !             3: 
        !             4: @implementation NSImage (NSImageAdditions)
        !             5: - (void) drawFlippedInRect:(NSRect) rect operation:(NSCompositingOperation) op fraction:(float) delta {
        !             6:        CGContextRef context;
        !             7: 
        !             8:        context = [[NSGraphicsContext currentContext] graphicsPort];
        !             9:        CGContextSaveGState( context ); {
        !            10:                CGContextTranslateCTM( context, 0, NSMaxY( rect ) );
        !            11:                CGContextScaleCTM( context, 1, -1 );
        !            12: 
        !            13:                rect.origin.y = 0;
        !            14:                [self drawInRect:rect fromRect:NSZeroRect operation:op fraction:delta];
        !            15:        } CGContextRestoreGState( context );
        !            16: }
        !            17: 
        !            18: - (void) drawFlippedInRect:(NSRect) rect operation:(NSCompositingOperation) op {
        !            19:     [self drawFlippedInRect:rect operation:op fraction:1.0];
        !            20: }
        !            21: 
        !            22: - (void)applyBadge:(NSImage*)badge withAlpha:(float)alpha scale:(float)scale
        !            23: {
        !            24:     if (!badge)
        !            25:         return;
        !            26:     
        !            27:     [badge setScalesWhenResized:YES];
        !            28:     [badge setSize:NSMakeSize([self size].width * scale,[self size].height * scale)];
        !            29:     
        !            30:     [self lockFocus];
        !            31:     [[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh];
        !            32:     [badge dissolveToPoint:NSMakePoint([self size].width - [badge size].width,0) fraction:alpha];
        !            33:     [self unlockFocus];
        !            34: }
        !            35: 
        !            36: @end

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>