Re: Drawing an NSImage into a custom NSView
Re: Drawing an NSImage into a custom NSView
- Subject: Re: Drawing an NSImage into a custom NSView
- From: Charles Srstka <email@hidden>
- Date: Tue, 15 Oct 2002 22:04:08 -0500
All I know is that it is a quick way to just draw the entire image, and
that it works when I do it.
However, looking at his code again, I see that it's not the solution to
the problem after all - the actual problem is probably caused by the
fact that the drawInRect command is not wrapped in a -[NSView
lockFocus] and -[NSView unlockFocus]. If those methods are added, it
will probably work.
Charles
On Tuesday, October 15, 2002, at 09:46 PM, David Remahl wrote:
Is that allowed!? Is it documented?
/ Rgds, David
Change fromRect:imageRect to fromRect:NSZeroRect and see if that
helps.
Charles
On Tuesday, October 15, 2002, at 04:53 PM, mw wrote:
Hello,
I have a custom control (subclass of NSView, obviously), and I can't
seem to
get it to draw into itself. Each instance of the custom control has
one
instance variable (for now) which stores the image it is to draw, and
some
methods (which aren't important because I am not calling them yet).
Here is my drawRect overload that I have in the subclass's
implementation:
- (void)drawRect:(NSRect)rect {
NSRect imageRect, controlRect;
imageRect.origin.x = 0.0;
imageRect.origin.y = 0.0;
imageRect.size = [imageToDraw size];
controlRect = [self bounds];
[imageToDraw drawInRect:controlRect
fromRect:imageRect
operation:NSCompositeCopy
fraction:1.0];
}
The image is loaded from the bundle and stored in the instance
variable
beforehand. I did a test that had the image be saved as a TIFF file
so
I
could make sure the images weren't garbage, and the TIFFs were
exactly
what
they were supposed to be, so I know that isn't the problem. The image
simply
doesn't want to draw, so I get a nice blank space where it is
supposed
to
be.
Anyone have any ideas on this one? It didn't seem to hard to me at
first to
get an image to draw, but now it is proving to be quite a hassle.
TIA,
mw
_______________________________________________
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.