Problem draw line by Quartz 2D with alpha property < 1.0 on iPhone

Posted by The Khanh on Stack Overflow See other posts from Stack Overflow or by The Khanh
Published on 2010-05-14T02:38:11Z Indexed on 2010/05/14 2:44 UTC
Read the original article Hit count: 355

Hello Everybody !

This code i use to draw in my app. So i have problem, if i draw with alpha property = 1. It is very good but if i change alpha property = 0.2 then my paint is not good. How do i make for better with alpha property = 0.2.

http://www.flickr.com/photos/9601621@N05/page1/

Draw with alpha = 1: It is good Draw with alpha = 0.2: It is bad

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

if ([self.view superview] && (headerView.frame.origin.y == -30)) { mouseSwiped = YES;

UITouch *touch = [touches anyObject]; CGPoint currentPoint = [touch locationInView:self.view]; currentPoint.y -= 20;

UIGraphicsBeginImageContext(self.view.frame.size);

CGContextRef context = UIGraphicsGetCurrentContext();

[drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; CGContextSetLineCap(context, kCGLineCapRound); CGContextSetLineWidth(context, currentBrushProperty.brushSize); CGContextSetRGBStrokeColor(context, [self red], [self green], [self blue], currentBrushProperty.brushTransparency); CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.0, 1.0);

CGContextBeginPath(context); CGContextMoveToPoint(context, lastPoint.x, lastPoint.y); CGContextAddLineToPoint(context, currentPoint.x, currentPoint.y);

CGContextStrokePath(context); drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();

lastPoint = currentPoint;

}}

Help me, please.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about quartz2d