Tuesday, November 23, 2010

iPhone dev Stupidity 131: Quartz 2d coords

from Apple Doc:

Because you use a lower-left origin when drawing into a bitmap or PDF context, you must compensate for that coordinate system when rendering the resulting content into a view. In other words, if you create an image and draw it using the CGContextDrawImage function, the image will appear upside down by default. To correct for this, you must invert the y-axis of the CTM (by multiplying it by -1) and shift the origin from the lower-left corner to the top-right corner of the view.

If you use a UIImage object to wrap a CGImageRef you create, you do not need to modify the CTM. The UIImage object automatically compensates for the inverted coordinate system of the CGImageRef type.

No comments: