I have been browsing the Internet for two days now, and apparently I'm missing something. I am trying to achieve a skewing effect for a NSImageView
. I found this question on stack overflow, which suggests that it is possible. Also, in the Apple Documentation it suggests that a NSAffineTransform with a NSAffineTransformStruct
is allowed.
Nevertheless: it doesn't work. The only thing I am able to perform are NSAffineTransform rotateByDegrees
, NSAffineTransform scaleXBy:foo yBy:foo
. Everything else doesn't show any apparent effect. I don't get any errors, just no result.
So my question is: is non-uniform scaling using NSAffineTransform
not allowed for Apps on OSX? And if so, why doesn't Xcode (at least) warn me for this? Or am I missing something here (like a programming mistake)?
Any help would be appreciated!
The code I'm using:
- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
// Drawing code here.
NSAffineTransform *rotate = [[NSAffineTransform alloc] init];
NSGraphicsContext *context = [NSGraphicsContext currentContext];
[context saveGraphicsState];
[currentImage lockFocus];
[rotate setTransformStruct:currentTransForm]; //This is filled in another routine
[rotate concat];
/* Your drawing code [NSImage drawAtPoint....]for the image goes here
Also, if you need to lock focus when drawing, do it here. */
CGRect imageRect = dirtyRect;
[self.image drawInRect:imageRect fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0];
[self.image unlockFocus];
[context restoreGraphicsState];
}