0

「描画」プロジェクトに取り組んでいます。私のプロジェクトは画面上でうまく機能します。しかし、網膜スクリーンでテストすると、この網膜スクリーンのような画像が得られました ! ipad2でも問題なく動作します。

私のコードの一部:

  CGPoint mid1 = midPoint(previousPoint1, previousPoint2); 
        CGPoint mid2 = midPoint(currentPoint, previousPoint1);
        [curImage drawAtPoint:CGPointMake(0, 0)];
        CGContextRef context = UIGraphicsGetCurrentContext(); 
        [self.layer renderInContext:context];
        CGContextMoveToPoint(context, mid1.x, mid1.y);
        CGContextAddQuadCurveToPoint(context, previousPoint1.x, previousPoint1.y, mid2.x, mid2.y); 
        if(previousPoint1.x == previousPoint2.x && previousPoint1.y == previousPoint2.y && previousPoint1.x == currentPoint.x && previousPoint1.y == currentPoint.y)
        {
            CGContextSetLineCap(context, kCGLineCapRound);

        }
        else 
        {
            CGContextSetLineCap(context, kCGLineCapRound);
        }

        CGContextSetBlendMode(context, kCGBlendModeNormal);
        CGContextSetLineJoin(context, kCGLineJoinRound);
        CGContextSetLineWidth(context, self.lineWidth);
        CGContextSetStrokeColorWithColor(context, self.lineColor.CGColor);
        CGContextSetShouldAntialias(context, YES);  
        CGContextSetAllowsAntialiasing(context, YES); 
        CGContextSetFlatness(context, 0.1f);
        CGContextSetAlpha(context, self.lineAlpha);
        CGContextStrokePath(context); 


- (void) calculateMinImageArea:(CGPoint)pp1 :(CGPoint)pp2 :(CGPoint)cp{

CGPoint mid1 = midPoint(pp1, pp2); CGPoint mid2 = midPoint(cp, pp1);

CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, mid1.x, mid1.y);
CGPathAddQuadCurveToPoint(path, NULL, pp1.x, pp1.y, mid2.x, mid2.y);
CGRect bounds = CGPathGetBoundingBox(path);
CGPathRelease(path);

CGRect drawBox = bounds;

//Pad our values so the bounding box respects our line width
drawBox.origin.x        -= self.lineWidth * 1;
drawBox.origin.y        -= self.lineWidth * 1;
drawBox.size.width      += self.lineWidth * 2;
drawBox.size.height     += self.lineWidth * 2;

UIGraphicsBeginImageContext(drawBox.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
curImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

[self setNeedsDisplayInRect:drawBox];
[[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode beforeDate: [NSDate date]];


  CGPoint midPoint(CGPoint p1, CGPoint p2)
{
    return CGPointMake((p1.x + p2.x) * 0.5, (p1.y + p2.y) * 0.5);}
4

0 に答える 0