Re: drawing flipped images
Re: drawing flipped images
- Subject: Re: drawing flipped images
- From: Jerry LeVan <email@hidden>
- Date: Mon, 5 Jul 2004 10:59:04 -0400
I use this in ImageBrowser-0.9 (Thank Florent Pillet)
Jerry
-(IBAction)flipHorizontal:(id)sender
{
NSImage *tmpImage;
NSAffineTransform *transform = [NSAffineTransform transform];
NSSize dimensions = [[bigImage image]size];
NSAffineTransformStruct flip = {-1.0, 0.0, 0.0, 1.0,
dimensions.width, 0.0 };
tmpImage = [[NSImage alloc] initWithSize:dimensions];
[tmpImage lockFocus];
[transform setTransformStruct:flip];
[transform concat];
[[bigImage image] drawAtPoint:NSMakePoint(0,0)
fromRect:NSMakeRect(0,0, dimensions.width, dimensions.height)
operation:NSCompositeCopy fraction:1.0];
[tmpImage unlockFocus];
[bigImage setImage: tmpImage];
[bigView setImage:tmpImage];
[tmpImage release];
}
-(IBAction)flipVertical:(id)sender
{
NSImage *tmpImage;
NSAffineTransform *transform = [NSAffineTransform transform];
NSSize dimensions = [[bigImage image]size];
NSAffineTransformStruct flip = {1.0, 0.0, 0.0, -1.0, 0.0,
dimensions.height};
tmpImage = [[NSImage alloc] initWithSize:dimensions];
[tmpImage lockFocus];
[transform setTransformStruct:flip];
[transform concat];
[[bigImage image] drawAtPoint:NSMakePoint(0,0)
fromRect:NSMakeRect(0,0, dimensions.width, dimensions.height)
operation:NSCompositeCopy fraction:1.0];
[tmpImage unlockFocus];
[bigImage setImage: tmpImage];
[bigView setImage:tmpImage];
[tmpImage release];
}
On Jul 5, 2004, at 10:03 AM, email@hidden wrote:
Cc: email@hidden
From: Allan Odgaard <email@hidden>
Subject: Re: drawing flipped images
Date: Mon, 5 Jul 2004 16:01:40 +0200
To: Chuck Soper <email@hidden>
On 5. Jul 2004, at 8:21, Chuck Soper wrote:
What is the best solution for this issue? Do I need two copies of each
image in memory, one flipped and one not flipped? Or, is there an
easier better way?
Changing the state of "isFlipped" does not change the actual image
data, so you can toggle it all you want. Or you can toggle it before
drawing to the NSImageCell context, or you can apply an affine
transform to flip the image...
But you certainly do not need two copies! :)
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.