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 21:33:55 -0500
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.
_______________________________________________
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.