Problem: drawing NSView to NSImage
Problem: drawing NSView to NSImage
- Subject: Problem: drawing NSView to NSImage
- From: Max Seelemann <email@hidden>
- Date: Fri, 22 Aug 2003 15:46:30 +0200
Hi guys.
I got a problem:
I want a special section of an NSView drawn in an NSImage (for an
Dragging session).
If I do this with dataWithPDFInsideRect: it's very slow, too slow.
As I don't need subviews, I tried drawRect: but this doesn't give the
expected result. The image
contains the view, but it's incorrectly (maybe a mirrored coordinate
system error). So both ways
don't work (good) for me. Can you help me fixing the error in the
second way? My code:
<--- snip --->
// rect is the NSRect that should be in the NSImage
img1 = [[NSImage alloc] initWithSize: [self frame].size];
[img1 lockFocus];
[self drawInRect: [self frame]];
[img1 unlockFocus];
img2 = [[NSImage alloc] initWithSize: rect.size];
[img2 lockFocus];
[img1 drawInRect:NSMakeRect(0, 0, rect.size.width,
rect.size.height) fromRect:rect operation:NSCompositeCopy fraction:0.7];
[img2 unlockFocus];
<--- snip --->
thanks,
MAX
_______________________________________________
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.