2010年12月2日星期四

NSImage Transformation - Flip

Today a lot of time was wasted on deal with image transformation due to lack of investigation about the properties of drawing in Cocoa.

I can't make the transform context effect only on the image I want to transform but the whole NSView owning the image. After using "lockfocus", nothing is drawn becox of the wrong implementation of the coordination system.
The pain ended after I kw about the difference between "bounds" and "frame" on Stackoverflow

To make the "lock" function, it seems that the "frame" need to be set correctly and after the "lock" the drawing is easy.

Here is a simple sample of flipping a NSImage with the NSAffineTransform class. The image is drawn from its middle bottom.

沒有留言:

發佈留言