• 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
Non-default origin scaling problem (NSAffineTransformation)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: NSTextField delegate how to?
  • Next by Date: Re: Finding applications that link to framework
  • Previous by thread: NSArray not re-sorting when the value of its sort descriptor key changes
  • Next by thread: QTMovieView and NSViewAnimation
  • Index(es):
    • Date
    • Thread