Be sure to check the endianness of the computer when choosing the pixel format. The original ImageWriter plugin has this code:

#if __BIG_ENDIAN__
    pixelFormat = QCPlugInPixelFormatARGB8;
#else
    pixelFormat = QCPlugInPixelFormatBGRA8;
#endif


On Apr 16, 2008, at 2:37 AM, Alex Drinkwater wrote:

Answered my own question!

I just replaced

pixelFormat = QCPlugInPixelFormatARGB8;

with

pixelFormat = QCPlugInPixelFormatBGRA8;

recompiled, and now the plugin works fine!

Apologies for wasting your time, guys,

alx




----- Original Message ----
From: Alex Drinkwater <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, 16 April, 2008 10:28:40 AM
Subject: Image Writer Plugin

There seems to be an issue with the Image Writer plugin (from the Developer/Examples/Quartz Composer/Plugins folder) on Intel machines. I've done some tests, and determined that it's swapping the RGBA channels of the captured image so that they become GRAB (ie Red becomes Green, Green becomes Red, Blue becomes Alpha, and the Alpha is swapped with the Blue channel).

I've tried swizzling the color channels of the image before they go into the Image Writer plugin, but this doesn't seem to make any difference to the output, which is odd, because if I pipe the output of the swizzle CIFilter to a billboard, the channels appear reordered as I'd expect.

I'm guessing this is some kind of endian-related issue. Anyone know how this might be fixed?

I've managed to isolate the part of the code in the XCode project relating to colorspaces, if this helps at all:

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

/* Figure out pixel format and colorspace to use */
        colorSpace = [qcImage imageColorSpace];
        if(CGColorSpaceGetModel(colorSpace) == kCGColorSpaceModelMonochrome)
        pixelFormat = QCPlugInPixelFormatI8;
        else if(CGColorSpaceGetModel(colorSpace) == kCGColorSpaceModelRGB)
        pixelFormat = QCPlugInPixelFormatARGB8;
        else
        return NO;
        
/* Get a buffer representation from the image in its native colorspace */ if(![qcImage lockBufferRepresentationWithPixelFormat:pixelFormat colorSpace:colorSpace forBounds:[qcImage imageBounds]])
        return NO;
        
        /* Create CGImage from buffer */
dataProvider = CGDataProviderCreateWithData(NULL, [qcImage bufferBaseAddress], [qcImage bufferPixelsHigh] * [qcImage bufferBytesPerRow], NULL); cgImage = CGImageCreate([qcImage bufferPixelsWide], [qcImage bufferPixelsHigh], 8, (pixelFormat == QCPlugInPixelFormatI8 ? 8 : 32), [qcImage bufferBytesPerRow], colorSpace, (pixelFormat == QCPlugInPixelFormatI8 ? 0 : kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host), dataProvider, NULL, false, kCGRenderingIntentDefault);
        CGDataProviderRelease(dataProvider);
        if(cgImage == NULL) {
                [qcImage unlockBufferRepresentation];
                return NO;
        }


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

Cheers,

alx
http://machinesdontcare.wordpress.com

Yahoo! for Good helps you make a difference


Yahoo! for Good helps you make a difference _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list ([email protected] )
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/tkoelling%40apple.com

This email sent to [EMAIL PROTECTED]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to