NSImage origin
NSImage origin
- Subject: NSImage origin
- From: Don Willems <email@hidden>
- Date: Wed, 22 Sep 2004 23:21:21 +0200
Hi,
Is it possible to change the origin of an NSImage?
My problem is this:
I have a custom NSView in which I can draw. I want to create an image
(on file) of the part of the custom view in which I have drawn. For
instance I have a view of 800x600 pixels. I have drawn a figure in the
rectangle with origin (100,150) and with size 100x100. The result
should be an image of size 100x100 with the same content as the
rectangle in the NSView. The coordinates (0,0) in the image should
correspond with (100,150) in the NSView.
I know how I can translate the origin in an NSView, but I don't know
how to do it in an image.
This is my code, where cropped is the rectangle in which I have drawn
and which may have an origin other than (0,0).
image = [[[NSImage alloc] initWithSize:cropped.size]
autorelease];
[image lockFocus];
[self drawViewRect:cropped];
[image unlockFocus];
At this moment the result is an image with the same content as the
NSView in the rectangle (0,0) and size 100x100. (Which I would expect,
but don't want.)
Thanks,
Don
_______________________________________________
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