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: NSImage to output port of a custom patch



you will most likely need to use an NSBitmapImageRep or a CVPixelbuffer to provide raw pixel values, and then output an image provider using your QCContexts incredibly long:

- (id) outputImageProviderFromBufferWithPixelFormat:(NSString*)format pixelsWide:(NSUInteger)width pixelsHigh:(NSUInteger)height baseAddress:(const void*)baseAddress bytesPerRow:(NSUInteger)rowBytes releaseCallback:(QCPlugInBufferReleaseCallback)callback releaseContext:(void*)context colorSpace:(CGColorSpaceRef)colorSpace shouldColorMatch:(BOOL)colorMatch

method.

The release context is not a GL context or anything, just a void * you can pass in to your release function to point it at whatever you want to make your life easier.


Here is working code from a CVPixelBuffer to an output port, where aBuffer is just an unsigned char* buffer. Im pretty sure you can do that same with NSBitmapImageRep

CVReturn error = CVPixelBufferCreateWithBytes(NULL, width, height, k32ARGBPixelFormat, aBuffer, rowBytes, NULL, NULL, NULL, &cvImageBuffer);

if(CVPixelBufferLockBaseAddress(cvImageBuffer,0) == kCVReturnSuccess)
{
provider = [context outputImageProviderFromBufferWithPixelFormat:QCPlugInPixelFormatARGB8 pixelsWide:width pixelsHigh:height baseAddress:CVPixelBufferGetBaseAddress(cvImageBuffer) bytesPerRow:CVPixelBufferGetBytesPerRow(cvImageBuffer) releaseCallback:_BufferReleaseCallback releaseContext:NULL colorSpace:CGColorSpaceCreateWithName(kCGColorSpaceGenericRGBLinear) shouldColorMatch:YES];
CVPixelBufferUnlockBaseAddress(cvImageBuffer,0);
}


Hope this helps!


On Jul 5, 2009, at 12:08 PM, Adrian Lo wrote:

Dear all,

I'm having some trouble trying to proceed with this custom patch that I've got. The patch basically accepts some numeric input parameters which determines what data to grab from a URL, and renders the results into an image to be send out via the output port of the patch.

I've got the image generated nicely as a NSImage, and I'm not stuck on how to send the NSImage to the output port. Would really appreciate some pointers on this, as I'm not even sure if I should be using NSImage for such operations or not.

thanks in advance,

Adrian

_______________________________________________
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

 _______________________________________________
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: 
 >NSImage to output port of a custom patch (From: Adrian Lo <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.