Re: Drawing an NSImage into a GWorld
Re: Drawing an NSImage into a GWorld
- Subject: Re: Drawing an NSImage into a GWorld
- From: Scott Thompson <email@hidden>
- Date: Thu, 14 Jul 2005 08:43:37 -0500
On Jul 12, 2005, at 12:38 PM, Dave Hersey wrote:
Check out the CocoaCreateMovie sample for one approach.
Specifically in:
http://developer.apple.com/samplecode/CocoaCreateMovie/listing3.html
Find CopyNSImageToGWorld at the bottom.
This code will replace the existing bitmap data in the GWorld, not
merge
pixels. It doesn't sound like that matters in your case. If it
does, you
could handle that several ways.
- Dave
I wonder if you could do something like this instead (typed into mail):
CGContextRef gworldCGContext;
QDBeginCGContext(yourGWorld, &gworldCGContext);
NSGraphicsContext *gworldNSContext = [NSGraphicsContext
graphicsContextWithGraphicsPort: (void *)gworldCGContext flipped:
false];
NSGraphicsContext *savedContext = [NSGraphicsContext currentContext];
[NSGraphicsContext setCurrentContext: gworldNSContext];
[myImage compositeToPoint: ... ]; // whichever routine you use to
draw the image itself
[NSGraphicsContext setCurrentContext: savedContext];
[gworldNSContext release];
gworldNSContext = NULL;
QDEndCGContext(yourGWorld, &gworldCGContext);
gworldCGContext = NULL;
I'm not sure about getting and setting the current NSGraphicsContext
for the thread. I don't think I've ever seen that done anywhere
else. It might work... it might cause your computer to go up in a
fireball though :-)
At any rate, this method would allow you to ignore the particulars of
how the NSImage is represented and would give the OS the greatest
opportunities to optimize drawing the image. The setup, however,
might outweigh the advantages (if the technique even works)
Scott
_______________________________________________
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