iOS图像处理之绘制直线

-(void)drawLine:(CGPoint)fromPnt toPoint:(CGPoint)toPnt{

    

    float xScale = theImageView.image.size.width/theImageView.frame.size.width;

    float yScale = theImageView.image.size.height/theImageView.frame.size.height;

    

    UIGraphicsBeginImageContext(theImageView.image.size);

    [theImageView.image drawInRect:CGRectMake(0, 0, theImageView.image.size.width, theImageView.image.size.height)];

    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapSquare);

    CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 2.0*[self returnMax:xScale withNumber:yScale]);

    CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(), YES);

    CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);

    CGContextBeginPath(UIGraphicsGetCurrentContext());

    CGContextMoveToPoint(UIGraphicsGetCurrentContext(), fromPnt.x*xScale, fromPnt.y*yScale);

    CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), toPnt.x*xScale, toPnt.y*yScale);

    CGContextStrokePath(UIGraphicsGetCurrentContext());

    theImageView.image=UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

}











本文转自 卓行天下  51CTO博客,原文链接:http://blog.51cto.com/9951038/1772572,如需转载请自行联系原作者
上一篇:Java常量池解析与字符串intern简介


下一篇:SAP Spartacus localStorage 里存储的 auth Token 过期时间