I see APIs in Quartz for drawing lines and circles. But all I want to do is to specify the (x,y) cartesian coordinate to color a pixel a particular value. How do I do that?
You can draw a 1-pixel-length line at the coordinate in question; that should accomplish what you want.
I should mention that I have tried drawing a zero length line (x1,y1) == (x2,y2). That did not work I do not want to draw a 1 pixel line. that messes up what I am trying to do
thanks
Quartz is not a pixel-oriented API, and its contexts aren’t necessarily pixel buffers. If you want to draw pixmaps, create a bitmap context with CGBitmapContextCreate()
. You provide a buffer, which you can manipulate directly, and can copy to another context by creating a CGImage
from the same buffer using CGImageCreate()
and drawing that.
I got a point (zero length line) to draw after setting the line-caps to kCGLineCapRound. The default line-cap has no length so can't be drawn.
The argument that a point has no size is silly. The lines have no width but we can draw those (by using the "line width" from the draw state). A point should draw in exactly the same way, and with different line caps I believe it does.
Maybe this behavior is new?