Re: NSImage and flipping
Re: NSImage and flipping
- Subject: Re: NSImage and flipping
- From: "Louis C. Sacha" <email@hidden>
- Date: Mon, 16 Feb 2004 16:53:01 -0800
Hello...
The original poster has replied that it _did_ work, although that
post didn't show up in my inbox until after I sent my previous post.
So, apparently I was wrong, and I appologize to Allan for doubting
his solution, but...
Unless this is a feature added to 10.3 and not present in 10.2,
either there is something else going on in Bjorn's text drawing code,
or there is something wrong in the code I used as my test case?
For example, running in 10.2, with the following in a custom subclass
of NSView:
- (void)drawRect:(NSRect)rect
{
NSImage *normal = [[NSImage alloc] initWithSize:NSMakeSize(100,100)];
[normal setFlipped:FALSE];
[normal lockFocus];
NSRect filled = NSMakeRect(0,0,100,50);
[[NSColor greenColor] set];
NSRectFill(filled);
filled = NSMakeRect(0,50,100,50);
[[NSColor redColor] set];
NSRectFill(filled);
[normal unlockFocus];
[normal compositeToPoint:NSMakePoint(25,125) operation:NSCompositeCopy];
NSImage *flipped = [[NSImage alloc] initWithSize:NSMakeSize(100,100)];
[flipped setFlipped:TRUE];
[flipped lockFocus];
filled = NSMakeRect(0,0,100,50);
[[NSColor greenColor] set];
NSRectFill(filled);
filled = NSMakeRect(0,50,100,50);
[[NSColor redColor] set];
NSRectFill(filled);
[flipped unlockFocus];
[flipped setFlipped:FALSE];
[flipped compositeToPoint:NSMakePoint(25,225) operation:NSCompositeCopy];
[normal release];
[flipped release];
}
If the simple setFlipped: solution for drawing the image should
work, then the two resulting images would be different, one would
have the green rect on top and the other would have the green rect on
the bottom... However, both images end up being the same. The
coordinate system of the view has no effect on this, since both of
the images are set the same (unflipped) when they are composited...
As long as things are working for Bjorn's code, that's really all
that matters at this point, but if anyone notices something that
jumps out as being wrong in the code I used for my test case, I'd
appreciate if you let me know (although I'm not too worried about
it...).
Louis
Hello...
This doesn't actually work (the resulting image would be right side
up, but it would still have the text ordering problem that the
original poster is dealing with). See the previous posts in this
thread for more information (specifically that the NSImage instance
method setFlipped: only applies to how the image is displayed /
composited in the destination, not the coordinate system used when
the image is being drawn into...).
Louis
On 14. Feb 2004, at 10:08, Bjvrn Carlstrvm wrote:
I am trying to implement dragging from a custom view. The view is
flipped to make text-rendering work correctly. To drag a piece of
graphic from the view I create a NSImage. To get it to render the
text correctly I use SetFlipped:YES. Or so I thought... The image
comes out upside down!
> [...]
Could anybody tell me what I am missing here. And what is the solution?
You must setFlipped:NO before giving the image to drag:image:...
--
Private Mails To Allan At Top-House Dot DK
http://www.diku.dk/hjemmesider/studerende/duff/
_______________________________________________
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.