File:  [mozdev] / chimera / NSImageAdditions.m
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Tue Feb 26 11:49:01 2002 UTC (15 years, 8 months ago) by macserv
Branches: MAIN
CVS tags: HEAD
Checking in the underlying prefs structure, and a prefPane, also fir structural integrity.  Also including a couple categories to extend a couple Cocoa objects, and some project changes to support building with the bundled prefPanes.  Also, added a contrib directory to house user contributed artifacts.  To come soon: more prefPanes, and the colorized icon store, with pref-generated notifications to be picked up by toolbars.

#import "NSImageAdditions.h"
#import <Cocoa/Cocoa.h>

@implementation NSImage (NSImageAdditions)
- (void) drawFlippedInRect:(NSRect) rect operation:(NSCompositingOperation) op fraction:(float) delta {
	CGContextRef context;

	context = [[NSGraphicsContext currentContext] graphicsPort];
	CGContextSaveGState( context ); {
		CGContextTranslateCTM( context, 0, NSMaxY( rect ) );
		CGContextScaleCTM( context, 1, -1 );

		rect.origin.y = 0;
		[self drawInRect:rect fromRect:NSZeroRect operation:op fraction:delta];
	} CGContextRestoreGState( context );

- (void) drawFlippedInRect:(NSRect) rect operation:(NSCompositingOperation) op {
    [self drawFlippedInRect:rect operation:op fraction:1.0];

- (void)applyBadge:(NSImage*)badge withAlpha:(float)alpha scale:(float)scale
    if (!badge)
    [badge setScalesWhenResized:YES];
    [badge setSize:NSMakeSize([self size].width * scale,[self size].height * scale)];
    [self lockFocus];
    [[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh];
    [badge dissolveToPoint:NSMakePoint([self size].width - [badge size].width,0) fraction:alpha];
    [self unlockFocus];


FreeBSD-CVSweb <>