composite colors : CALayer and blend mode on iPhone
Posted
by Ali
on Stack Overflow
See other posts from Stack Overflow
or by Ali
Published on 2009-11-01T23:19:08Z
Indexed on
2010/06/01
9:53 UTC
Read the original article
Hit count: 575
I'm trying to use core image on the iphone. I'm able to composite my colors using quartz to draw an uiview, but i want to separate each component into CALayer (UIview consume more resources).
So i have a white mask i want to use to filter a background bitmap, and i want to try diffrent blending mode. UNfortunately, the layers are only "adding" their colors.
Here is my code :
@implementation WhiteLayerHelper
- (void)drawLayer:(CALayer *)theLayer
inContext:(CGContextRef)myContext
{
// draw a white overlay, with special blending and alpha values, so that the saturation can be animated
CGContextSetBlendMode(myContext,kCGBlendModeSaturation);
CGContextSetRGBFillColor(myContext,1.0,1.0,1.0,0.9);
CGContextFillRect(myContext,[UIScreen mainScreen].bounds);
}
@end
And here is the main view drawrect code, where i use my CALayer :
- (void)drawRect:(CGRect)rect {
//get the drawing context
CGContextRef myContext = UIGraphicsGetCurrentContext();
// draw the background
[self fillContext:myContext withBounds:m_overlayRect withImage:m_currentImage];
[whiteLayer renderInContext:myContext];
}
Is there something wrong ?
© Stack Overflow or respective owner