• 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
rotating an NSImage ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

rotating an NSImage ?


  • Subject: rotating an NSImage ?
  • From: Pejvan BEIGUI <email@hidden>
  • Date: Sun, 27 Apr 2003 22:04:26 +0200
  • Organization: Project:Omega

Hi all,

I've got a small (big?) issue with the NSImage instances: I can't find a
way to rotate them. According to the list archive, I found these two posts:

> NSImage documentation says:
>
> Images displayed using the various composite or dissolve methods, such
> as compositeToPoint:operation: or dissolveToPoint:fraction:, have the
> horizontal orientation of the base coordinate system; they can't be
> rotated or horizontally flipped. When composited, an image maintains
> this orientation, no matter what coordinate system it is composited to.
> (The destination coordinate system is used only to determine the
> location of a composited image, not its size or orientation.) Images can
> be flipped in the vertical direction by using setFlipped:.

this one tells me that I can't rotate NSImages (all my tries led me to
that conclusion)

According to a post by the some other people (I'm sorry I didn't catch
his name), it seems that something like should work ?:

NSImage * targetImage = [[NSImage alloc]
initWithSize:NSMakeSize(128,128)];
NSImage * currentImage = [[NSImage alloc]
initWithContentsOfFile:[[NSBundle
mainBundle] pathForImageResource:@"testImage"]];

bIconTransform = [NSAffineTransform transform];

[targetImage lockFocus];
[bIconTransform translateXBy:64 yBy:64];
[bIconTransform rotateByDegrees:15];
[bIconTransform translateXBy:-64 yBy:-64];
[bIconTransform scaleBy:0.95];
[bIconTransform set];


[targetImage lockFocus];
//[currentImage compositeToPoint:NSMakePoint(0,0)
operation:NSCompositeSourceOver];
[currentImage drawInRect:NSMakeRect(0,0,128,128)
fromRect:NSMakeRect(0,0,128,128)
operation:NSCompositeSourceOver
fraction:1];
[targetImage unlockFocus];

Thanks for any advice!

Pejvan
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: NSRegistrationDomain for another application?
  • Next by Date: Re: Hiding an NSTextField
  • Previous by thread: Re: NSRegistrationDomain for another application?
  • Next by thread: OSX EightyRes ?
  • Index(es):
    • Date
    • Thread