Transform and NSImageView
Transform and NSImageView
- Subject: Transform and NSImageView
- From: David Wilson <email@hidden>
- Date: Fri, 02 Dec 2005 21:54:23 +1300
Hello everyone...
I'm going around in circles here. I've searched the forums and my
cocoadev mail archives. Details on this subject seem to be thin. It's
either really easy so no one needs to ask or few people are doing
this stuff...
I have my own subclass of NSImageView, I'm trying to implement a
rotate, horizontal flip using key commands for the NSImageView. The
application is document based application, and this subclass custom
view occupies the whole document
What I want to know or understand is...
1. Why doesn't the image in my onscreen window automatically update.
It does when I resize the window.
2. What's happening? After the 3rd key press I've lost my image!
3. Is it valid for me to retrieve the "image" using [<view name>
image] and plop that into an NSImage?
4. Do I need lockFocus / unLockFocus?
5. Surely I have to release tmpImage, after all I've pushed the image
back via the setImage call?
Here's the code out of my NSImageView for "rotate" - I have chosen 5°
so that I can see the image move on screen.
NSLog(@"keyDown - rotate %@", [_iPicImageView image]);
NSImage *tmpImage;
NSAffineTransform *transform = [NSAffineTransform transform];
NSSize dimensions = [[self image] size];
tmpImage = [NSImage alloc];
tmpImage = [_iPicImageView image]; // do I need this line of code?
[tmpImage lockFocus];
[transform rotateByDegrees:5];
[transform concat];
[tmpImage drawAtPoint:NSMakePoint(0,0) fromRect:NSMakeRect(0,0,
dimensions.width, dimensions.height) operation:NSCompositeCopy
fraction:1.0];
[tmpImage unlockFocus];
[self setImage:tmpImage];
NSLog(@"keyDown - rotate %@", [_iPicImageView image]);
NSLog(@"keyDown - rotate %@", tmpImage);
[tmpImage release];
[self setNeedsDisplay:YES];
Here's the output from the console.
<first key press>
2005-12-02 21:41:26.449 iPic[5805] keyDown - rotate NSImage 0x347d30
Size={2560, 1920} Reps=(
NSBitmapImageRep 0x348030 Size={2560, 1920}
ColorSpace=NSCalibratedRGBColorSpace BPS=8 BPP=24 Pixels=2560x1920
Alpha=NO Planar=NO Format=0
)
2005-12-02 21:41:27.252 iPic[5805] keyDown - rotate NSImage 0x347d30
Size={2560, 1920} Reps=(
NSCachedImageRep 0x38cb80 Size={2560, 1920}
ColorSpace=NSCalibratedRGBColorSpace BPS=8 Pixels=2560x1920 Alpha=NO
)
2005-12-02 21:41:27.253 iPic[5805] keyDown - rotate NSImage 0x347d30
Size={2560, 1920} Reps=(
NSCachedImageRep 0x38cb80 Size={2560, 1920}
ColorSpace=NSCalibratedRGBColorSpace BPS=8 Pixels=2560x1920 Alpha=NO
)
<second key press>
2005-12-02 21:41:30.511 iPic[5805] keyDown - rotate NSImage 0x347d30
Size={2560, 1920} Reps=(
NSCachedImageRep 0x38cb80 Size={2560, 1920}
ColorSpace=NSCalibratedRGBColorSpace BPS=8 Pixels=2560x1920 Alpha=NO
)
2005-12-02 21:41:30.810 iPic[5805] keyDown - rotate NSImage 0x347d30
Size={2560, 1920} Reps=(
NSCachedImageRep 0x38cb80 Size={2560, 1920}
ColorSpace=NSCalibratedRGBColorSpace BPS=8 Pixels=2560x1920 Alpha=NO
)
2005-12-02 21:41:30.810 iPic[5805] keyDown - rotate NSImage 0x347d30
Size={2560, 1920} Reps=(
NSCachedImageRep 0x38cb80 Size={2560, 1920}
ColorSpace=NSCalibratedRGBColorSpace BPS=8 Pixels=2560x1920 Alpha=NO
)
<third key press>
2005-12-02 21:41:38.462 iPic[5805] keyDown - rotate (null)
2005-12-02 21:41:38.464 iPic[5805] keyDown - rotate (null)
2005-12-02 21:41:38.464 iPic[5805] keyDown - rotate (null)
Looking forward to hearing from anyone. Thank you in advance.
- David
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden