Non-default origin scaling problem (NSAffineTransformation)
Non-default origin scaling problem (NSAffineTransformation)
- Subject: Non-default origin scaling problem (NSAffineTransformation)
- From: Hisaoki Nishida <email@hidden>
- Date: Tue, 27 Sep 2005 18:26:46 -0700
Hi,
I am trying to scale an NSImage using a non-default origin, as in
this example image: <http://www.willamette.edu/~gorr/classes/
GeneralGraphics/Transforms/images/scaleHouseCent.gif>
I am applying the transformations in the correct order of:
1. translate the image's lower left corner to the origin,
2. perform scaling,
3. translate the image's lower left corner back to where it was,
where I want it drawn
The actual scaling is applied properly to the image, but the
positions are way off.
Here's my code:
NSAffineTransform * transform = [NSAffineTransform transform];
[transform translateXBy: position.x - (position.x * 2) yBy:
position.y - (position.y * 2)];
[transform scaleBy: scale];
[transform translateXBy: position.x yBy: position.y];
[transform set];
[image drawAtPoint: position
fromRect: NSMakeRect(0, 0, [image size].width, [image
size].height)
operation: NSCompositeSourceOver fraction: 1.0];
The image is being drawn on an NSView subclass. 'position' defines
the point to draw in view coordinates.
What is wrong with my code?
Thanks,
-hyn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden