I\'m trying to flip an NSImage created with a NSImageBitmapRep representation. After some digging (Flipping Quicktime preview & capture and Mirroring CIImage/NSImage) I
Anyway, I think a good idea should be posting a complete function. Here is my solution based on Ken post
- (NSImage *)flipImage:(NSImage *)image
{
NSImage *existingImage = image;
NSSize existingSize = [existingImage size];
NSSize newSize = NSMakeSize(existingSize.width, existingSize.height);
NSImage *flipedImage = [[[NSImage alloc] initWithSize:newSize] autorelease];
[flipedImage lockFocus];
[[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh];
NSAffineTransform *t = [NSAffineTransform transform];
[t translateXBy:existingSize.width yBy:existingSize.height];
[t scaleXBy:-1 yBy:-1];
[t concat];
[existingImage drawAtPoint:NSZeroPoint fromRect:NSMakeRect(0, 0, newSize.width, newSize.height) operation:NSCompositeSourceOver fraction:1.0];
[flipedImage unlockFocus];
return flipedImage;
}