Affine Transform
Affine Transform
- Subject: Affine Transform
- From: Terry Heaford <email@hidden>
- Date: Sat, 11 Feb 2006 20:29:12 +0000
A newbie question:
I am really struggling with affine transforms to rotate an image
contained in an NSView which is a subview of a scrollview.
The image is larger than than the visible size of the scrollview.
The code I have from drawRect is below:
if (image)
{
deg = 45;
NSRect imageRect = NSMakeRect(0,0,[image size].width,[image
size].height);
NSPoint imageDrawPoint = NSMakePoint([self visibleRect].size.width/
2, [self visibleRect].size.height/2);
NSAffineTransform *trans = [NSAffineTransform transform];
[trans translateXBy:imageDrawPoint.x yBy:imageDrawPoint.y];
[trans rotateByDegrees:deg];
[trans translateXBy:-imageDrawPoint.x yBy:-imageDrawPoint.y];
[trans concat];
[image drawAtPoint:NSZeroPoint fromRect:imageRect
operation:NSCompositeCopy fraction:opacity];
}
This seems to rotate the image correctly but how do I size the frame
or the bounds (not sure which or both) to the correct size for the
rotated image allowing it to be scrolled within the scrollview and
how do I locate the image within the frame correctly.
Thanks in advance
Terry
_______________________________________________
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