CIImage / NSImage Mirroring

I currently have the following

 CIImage *img = [CIImage imageWithCVImageBuffer: imageBuffer];

 NSCIImageRep *imageRep = [NSCIImageRep imageRepWithCIImage:img];
 NSImage *image = [[[NSImage alloc] initWithSize: [imageRep size]] autorelease];
 [image addRepresentation:imageRep];

This works fine, I can use NSImage, and when it is written to the file, the image exactly matches me.

However, I am pulling this image from iSight users using QTKit, so I need to flip this image along the y axis.

My first thought was to convert CIImage using something like this, however my final image always comes out completely blank. When writing to a file, the dimensions are correct, but appear empty.

- (CIImage *)flipImage:(CIImage *)image
{
    return [image imageByApplyingTransform:CGAffineTransformMakeScale(-1, 1)];
}

Am I approaching this wrong? Or did I make a mistake in my code?

0
source share
2 answers

, , , , . , , .

+3

- == >

    CGAffineTransform rotTrans = CGAffineTransformMakeRotation(M_PI_2);
    CGAffineTransform transTrans1 = CGAffineTransformTranslate(rotTrans, 0.0f, 320.0f);
    CGAffineTransform scaleTrans = CGAffineTransformScale(transTrans1, 1.0, -1.0);
    CGAffineTransform transTrans2 = CGAffineTransformTranslate(scaleTrans, -0.0f, -320.0f);

    self.view.transform = transTrans2;

, , , . . , , , , - .

+1

All Articles