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: Wed, 16 Oct 2002 02:37:48 -0500
Actually, I'm about to slap myself in the face for not thinking of
this: there's an even easier, and better performance-wise solution than
using NSZeroRect. It is, simply:
- (void)drawRect:(NSRect)aRect {
[self lockFocus];
[image drawInRect:aRect
fromRect:aRect
operation:NSCompositeSourceOver // or whatever composite
operation you want
fraction:1.0];
[self unlockFocus];
}
This is the way I would do it. It beats both the imgSize, srcRect
method and NSZeroRect, because if some of the view is not visible, only
the visible part gets drawn. And it's very easy to type, and very
obvious, and I really should have thought of it when writing my first
reply. Oh well.
Charles
On Tuesday, October 15, 2002, at 10:09 PM, David Remahl wrote:
>
> All I know is that it is a quick way to just draw the entire image,
>
> and
>
> that it works when I do it.
>
>
Ok. That is very interresting. I have always fonud the
>
>
NSSize imgSize = [img size];
>
NSRect srcRect = NSMakeRect( 0.0, 0.0, imgSize.width, imgSize.height );
>
[img drawImageFromRect:srcRect .....];
>
>
A real kludge. Using NSZeroRect would be nice both to performance
>
(although
>
not a lot) and to my typing fingers.
>
>
/ Rgds, David
>
_______________________________________________
>
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.