• 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
Question about NSImage and setFlipped
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question about NSImage and setFlipped


  • Subject: Question about NSImage and setFlipped
  • From: Joe Chan <email@hidden>
  • Date: Fri, 26 Nov 2004 16:06:01 -0500

I have a NSImage that I'd like to draw with NSImageInterpolationHigh into a flipped view. So I have the following code in drawRect:

- (void)drawRect: (NSRect)rect
{
NSImageRep *rep = [_image bestRepresentationForDevice: nil];
NSRect imgRect = {0, 0};
imgSize.size = [_image size];
NSImage *copy = [[NSImage alloc] initWithSize: imgRect.size];
[copy lockFocus];
[[NSGraphicsContext currentContext] setImageInterpolation: _imageInterpolation];
[rep drawInRect: imgRect];
[copy unlockFocus];
[copy setFlipped: [self isFlipped]];
[copy drawInRect: [self bounds] fromRect:
operation: NSCompositeSourceOver fraction: 1.0];
[copy release];
}


Which resulted in the image being drawn upside down. However, if I setFlipped before [copy lockFocus], it'll work properly. Reading the docs seems to imply that NSImage only uses the value passed into setFlipped for drawing into a view. Why must I setFlipped before drawing into the new NSImage for it to be drawn correctly?


----------- Joe Chan email@hidden http://www.firstian.com

_______________________________________________
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: Mac OS 10.3 Help - hyperlinks do not work
  • Next by Date: Re: setAutoresizingMask help
  • Previous by thread: RE: Mac OS 10.3 Help - hyperlinks do not work
  • Next by thread: Re: Cocoa-dev Digest, Vol 1, Issue 330
  • Index(es):
    • Date
    • Thread