Scale and NSCompositePlusDarker
Scale and NSCompositePlusDarker
- Subject: Scale and NSCompositePlusDarker
- From: Lorenzo <email@hidden>
- Date: Wed, 21 Jul 2004 20:56:06 +0200
Hi,
I would like to scale an NSImage and make it darker. I made the following.
The original image has been scaled properly, but the brigthness is the same
(not good). And I got the result in the original image itself and not as I
expected in the darkImage. Also the "Dark" image contains a gray square...
What did I make wrong?
- (void)ResizeDarker:(NSImage*)anImage oldSize:(NSSize)oldSize
newSize:(NSSize)newSize
{
NSImage *darkImage = [[NSImage alloc] initWithSize:newSize];
NSRect sourceRect = NSMakeRect(0, 0, oldSize.width, oldSize.height);
NSRect destRect = NSMakeRect(0, 0, newSize.width, newSize.height);
[anImage setScalesWhenResized:YES];
[anImage setSize:newSize];
[darkImage lockFocus];
[anImage drawInRect:destRect fromRect:sourceRect
operation:NSCompositePlusDarker fraction:0.5];
[darkImage unlockFocus];
[[anImage TIFFRepresentation] writeToFile:@"/Original.tiff"
atomically:YES];
// This image now contains a gray square. Strange. Why?
[[darkImage TIFFRepresentation] writeToFile:@"/Dark.tiff"
atomically:YES];
[darkImage release];
}
Best Regards
--
Lorenzo
email: email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.