私のiOSアプリケーションでは、CoreGraphicsを使用して曲線を描こうとしています。描画自体はうまく動作しますが、網膜ディスプレイでは同じ解像度で描画され、ピクセルは2倍になりません。結果はピクセル化されたイメージです。CoreGraphics - Image pixelatedを使用した網膜ディスプレイでの描画
私は、次の機能を使用して描画しています:私が見つけた
- (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
}
アドバイスはuse the scaleFactor
property、またはCGContextSetShouldAntialias()
functionにしたが、これらのいずれも、これまで助けました。 (私はそれらを不適切に使用したかもしれませんが)
ご協力いただければ幸いです。あなたは
if (UIGraphicsBeginImageContextWithOptions != NULL) {
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
} else {
UIGraphicsBeginImageContext(size);
}
UIGraphicsBeginImageContextWithOptionsでUIGraphicsBeginImageContextを交換する必要が
これは完全に機能します!ありがとうございました! – antalkerekes