• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Drawing an NSImage into a custom NSView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Drawing an NSImage into a custom NSView
      • From: Marco Binder <email@hidden>
References: 
 >Re: Drawing an NSImage into a custom NSView (From: David Remahl <email@hidden>)

  • Prev by Date: Re: How to avoid a Windows interface on OS X?
  • Next by Date: Re: Hardcopy Appkit Reference format?
  • Previous by thread: Re: Drawing an NSImage into a custom NSView
  • Next by thread: Re: Drawing an NSImage into a custom NSView
  • Index(es):
    • Date
    • Thread