Skip navigation.
 
mlAnyone else think this is a CIFilter bug?
FROM : Ken Tozier
DATE : Sat Apr 30 09:13:32 2005

I've only been using Affine transforms for a few days and CIFilters 
for about a week, but this seems like a bug in the 
"CIAffineTransform" filter.

// Load an image
NSImage    *sourceImage    = [[NSImage alloc] initWithContentsOfFile: 
@"path to an image file"];

// Convert to a CIImage
CIImage        *ciImage    = [[CIImage alloc] initWithData: 
[sourceImage TIFFRepresentation]];

// Create an affine transform
NSAffineTransform    *transform    = [NSAffineTransform transform];
[transform    translateXBy: 50 yBy: 50];

// Create a "CIAffineTransform" filter and add the transform above
CIFilter        *filter        = [CIFilter filterWithName: 
@"CIAffineTransform"];

[filter setDefaults];
[filter setValue: ciImage forKey: @"inputImage"];
[filter setValue: transform forKey: @"inputTransform"];

// Get the result
ciImage    = [filter valueForKey: @"outputImage"];

// Put result in an image rep, add to an image
NSCIImageRep    *imgRep      = [NSCIImageRep imageRepWithCIImage: 
ciImage];
NSImage          *resultImage  = [[NSImage alloc] initWithSize: 
sourceImage.size];

[resultImage addRepresentation: imgRep];

// display resultImage in a window.

Result: Image appears in the same location it would if none of the 
above had happened.

Other affine transforms work fine with the "CIAffineTransform" filter 
(rotate and scale) but not translate.

I thought I'd run it by a few more sets of eyes, in case I'm making 
an obvious error, before submitting a bug report.

Ken

Related mailsAuthorDate
No related mails found.