• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Affine Transform
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Affine Transform
      • From: Ian was here <email@hidden>
    • Re: Affine Transform
      • From: Greg Herlihy <email@hidden>
  • Prev by Date: Re: Modifying Info.plist at runtime
  • Next by Date: Re: Debugging problems - [resolved]
  • Previous by thread: Re: Debugging problems - [resolved]
  • Next by thread: Re: Affine Transform
  • Index(es):
    • Date
    • Thread