Na miña aplicación para iOS estou intentando debuxar curvas usando CoreGraphics. O debuxo en si funciona ben, pero na pantalla da retina a imaxe debúxase coa mesma resolución e non se duplica o píxel. O resultado é unha imaxe pixelada.
Estou debuxando empregando as seguintes funcións:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.canvasView];
UIGraphicsBeginImageContext(self.canvasView.frame.size);
[canvasView.image drawInRect:self.canvasView.frame];
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetShouldAntialias(ctx, YES);
CGContextSetLineCap(ctx, kCGLineCapRound);
CGContextSetLineWidth(ctx, 5.0);
CGContextSetRGBStrokeColor(ctx, 1.0, 0.0, 0.0, 1.0);
CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(ctx, currentPoint.x, currentPoint.y);
CGContextStrokePath(ctx);
canvasView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = currentPoint;
// some code omitted from this example
}
O consello que atopei foi usar a propiedade scaleFactor
ou a Función CGContextSetShouldAntialias ()
, pero ningún destes axudou ata o momento. (Aínda que podería usalos de xeito inadecuado.)
Calquera axuda agradeceríase moito.