Re: Simulate Photoshop's "Overlay" compositing method
Re: Simulate Photoshop's "Overlay" compositing method
- Subject: Re: Simulate Photoshop's "Overlay" compositing method
- From: Jesse Grosjean <email@hidden>
- Date: Thu, 2 Nov 2006 10:26:40 -0500
I'm reviving this old thread because I have the same need. Here's
what I'm trying to simulate in photoshop:
1. Double click on Photoshop layer to open layer style panel.
2. Check "Color Overlay".
3. Choose a "Blend Mode" of "Darken".
4. Choose an Opacity of 100%.
The goal is to replace white with the overlay color, while leaving
dark alone.
I can come close with this modified code from the archives:
NSSize theSize = [originialImage size];
NSImage *theNewImage = [[[NSImage alloc] initWithSize:theSize]
autorelease];
[theNewImage lockFocus];
[originialImage compositeToPoint:NSZeroPoint
operation:NSCompositeSourceOver];
[tintColor set];
[[NSGraphicsContext currentContext]
setCompositingOperation:NSCompositePlusDarker];
NSRect r = NSZeroRect;
r.size = [theNewImage size];
[inTint setFill];
[NSBezierPath fillRect:r];
[theNewImage unlockFocus];
return theNewImage;
But it's not handling transparency in the original image that way
that I would like. In the above code transparent regions in the
original image will be filled with 100% of the tintColor. Instead I
want transparency in the original image to be persevered in theNewImage.
Thanks for any help or pointers.
Jesse
I am just wondering if there is a convenient (read: easy, fast,
etc.) way of simulating Adobe Photoshop's "Overlay" layer
compositing mode. This would essentially be used to tint images.
Whatever solution exists would have to work in Panther as well as
later versions of Mac OS X, so anything that's CI-only is out :-/
I'll assume you have an NSImage you're starting with? If so, render
the image, set an appropriate tint color and use
NSRectFillUsingOperation to fill a particular area.
For example, set a color with a low alpha value and use the
NSCompositeSourceOver operation with NSRectFillUsingOperation.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden