Re: Composing a darker image
Re: Composing a darker image
- Subject: Re: Composing a darker image
- From: Chris Giordano <email@hidden>
- Date: Fri, 22 Aug 2003 11:49:59 -0400
Tito,
I don't think you can do it by simply drawing "with more alpha" like
you can do to draw it lighter. (I could be wrong.)
However, what you can do is draw over it with a semi-transparent black.
This should have the same effect. Below is some code that I used to
darken a clicked-on image. No guarantees it will work entirely in your
case, but hopefully this will at least get you pointed toward a
solution.
chris
----
// returns retained copy of image, with highlighting applied
- (NSImage *) retainedHighlightedImageForImage:(NSImage *)image
{
NSImage * newImage;
NSSize newSize;
if (!image) return nil;
newSize = [image size];
newImage = [[NSImage alloc] initWithSize:newSize];
[newImage lockFocus];
[image drawAtPoint:NSZeroPoint fromRect:NSMakeRect(0, 0,
newSize.width, newSize.height) operation:NSCompositeSourceOver
fraction:1.0];
[[[NSColor blackColor] colorWithAlphaComponent: .5] set];
NSRectFillUsingOperation(NSMakeRect(0, 0, newSize.width,
newSize.height), NSCompositeSourceAtop);
[newImage unlockFocus];
return newImage;
}
On Friday, August 22, 2003, at 10:43 AM, Tito Ciuro wrote:
Hello,
I need to draw a darker image of a given TIFF-based image. The lighter
version was easy:
[image compositeToPoint: NSMakePoint(iconStatesRect.origin.x,
iconStatesRect.origin.y)
operation: NSCompositeSourceOver
fraction: 0.5];
A fraction of 1.0 represents the original picture, but I need to
darken the image a bit, just the way an icon reacts to a click on a
toolbar, for example. How can I do this?
Thanks,
-- Tito
_______________________________________________
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.