Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving the result of processing an image to another image



Then, I create a QCView, sized to the desired output image size.  I set the content view of my offscreen window to be my QCView.

Next, you'd hook up your image object to the view, something like this:

        success = [myQCView setValue:myImage forInputKey:@"Image"];

Now you are ready to "run" the composition.

    BOOL started = [myQCView startRendering];

That's enough to make it generate its first frame, which, if you're using QC for still images, is enough.  It's time to get the output image.

            image = [myQCView valueForOutputKey:@"Image"]; // image with NSCGImageRep

Then, you can stop rendering: [myQCView stopRendering];

What's you describe here works, although it could be a lot more optimized: using a QCRenderer instead of a QCView and not do start / render / stop for every frame as it prevents any caching of resources.

In your current implementation, you might not even need to create a background window, just the QCView. Or even better, something like this might work:

NSString*                        compositionPath = @"?"; //Set to composition path
NSOpenGLPixelFormatAttribute    attributes[] = {NSOpenGLPFAAccelerated, NSOpenGLPFANoRecovery, (NSOpenGLPixelFormatAttribute)0};
NSAutoreleasePool*                pool = [NSAutoreleasePool new];
NSOpenGLPixelFormat*            format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
NSOpenGLContext*                context = [[NSOpenGLContext alloc] initWithFormat:format shareContext:nil];
QCRenderer*                        renderer = [[QCRenderer alloc] initWithOpenGLContext:context pixelFormat:format file:compositionPath];

//Do the following for each image to be processed by the composition
{
    //Set composition input parameters here - like numerical values, images...
    //[renderer setValue:? forInputKey:@"Image"];

    

    //Run composition
    [renderer renderAtTime:0.0 arguments:nil];

    

    //Retrieve composition output results here
    //image = [renderer valueForOutputKey:@"Image"];
}

[renderer release];
[context release];
[format release];
[pool release];


________________________________________________________

Pierre-Olivier Latour                            email@hidden

Quartz Composer Architect                Graphic & Imaging Team


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/email@hidden

This email sent to email@hidden

References: 
 >Saving the result of processing an image to another image (From: Benoit Marchant <email@hidden>)
 >Re: Saving the result of processing an image to another image (From: Dan Wood - Discussion Lists <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.