FROM : Joe Chan
DATE : Fri Nov 26 22:06:01 2004
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_removed>
http://www.firstian.com
DATE : Fri Nov 26 22:06:01 2004
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_removed>
http://www.firstian.com
| Related mails | Author | Date |
|---|---|---|
| No related mails found. | ||






Cocoa mail archive

