9
在我的iOS應用程序中,我嘗試使用CoreGraphics繪製曲線。繪圖本身工作正常,但在視網膜顯示器上,圖像使用相同的分辨率繪製,並且不會像素加倍。結果是一個像素化的圖像。使用CoreGraphics繪製視網膜顯示 - 圖像像素化
我使用以下功能圖紙:
- (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,但至今沒有這些幫助。 (雖然我可能使用不當。)
任何幫助將不勝感激。
它完美的作品!謝謝! – antalkerekes