En mi aplicación iOS, estoy tratando de dibujar curvas usando CoreGraphics. El dibujo en sí funciona bien, pero en la pantalla retina la imagen se dibuja con la misma resolución y no se duplica el píxel. El resultado es una imagen pixelada.Dibujar en la pantalla retina usando CoreGraphics - Imagen pixelada
Estoy dibujando mediante las siguientes funciones:
- (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
}
El consejo que he encontrado era use the scaleFactor
property, o la CGContextSetShouldAntialias()
function, pero ninguno de estos ayudado hasta ahora. (Aunque podría haberlos utilizado incorrectamente.)
Cualquier ayuda sería muy apreciada.
¡Funciona a la perfección! ¡Gracias! – antalkerekes