Re: drawing text onto an NSImage
Re: drawing text onto an NSImage
- Subject: Re: drawing text onto an NSImage
- From: Douglas Davidson <email@hidden>
- Date: Fri, 1 Dec 2006 13:24:36 -0800
On Dec 1, 2006, at 12:47 PM, Ben Zotto wrote:
I would like to pre-cache some of this drawn text in some cases by
drawing into an NSImage (using the 10.3 lockFocus/draw/unlockFocus
technique) before compositing it to the screen. The NSImage has
been set to flipped, but the text still
comes out wrong on it, with each individual line being vertically
mirrored, something that (unless I'm not bright enough to get it)
can't
be fixed by applying an NSAffineTransform. Calling
[[NSGraphicsContext
currentContext] isFlipped] returns NO when drawing to the image, which
is implied by the documentation and I assume somewhere at the cause
of the problem.
Here is something adapted from currently working code, showing how to
draw text into an NSImage:
image = [[NSImage alloc] initWithSize:size];
[image setFlipped:YES];
[image lockFocus];
[layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:point];
[image unlockFocus];
Douglas Davidson
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden