Reputation: 161
I use CGContextStrokePath painted on a straight line in a white background picture, stroke color is red, alpha is 1.0 After drawing the line, why the points is not (255, 0, 0), but (255, 96, 96) Why not pure red?
Upvotes: 1
Views: 498
Reputation: 385500
Quartz (the iOS drawing layer) uses antialiasing to make things look smooth. That's why you're seeing non-pure-red pixels.
If you stroke a line of width 1.0 and you want only pure red pixels, the line needs to be horizontal or vertical and it needs to run along the center of the pixels, like this:
CGContextMoveToPoint(gc, 0, 10.5);
CGContextAddLineToPoint(gc, 50, 10.5);
CGContextStroke(gc);
The .5 in the y coordinates puts the long along the centers of the pixels.
Upvotes: 2