Re: Why use NSCustomImageRep for drawing in code in NSImage?
Re: Why use NSCustomImageRep for drawing in code in NSImage?
- Subject: Re: Why use NSCustomImageRep for drawing in code in NSImage?
- From: Ken Thomases <email@hidden>
- Date: Sun, 14 Dec 2014 21:38:20 -0600
On Dec 14, 2014, at 8:53 PM, Jerry Krinock <email@hidden> wrote:
> I’m modernizing the old images on some buttons in an OS X app, replacing their .png resources with simple line art, drawn in code. In so doing I stumbled across Daniel Jalkut’s old LittleYellowGuy demo [1], in which the drawing code is in the delegate of a NSCustomImageRep, which is added to an empty image. I’ve always done this instead by sending -lockFocus to an empty image and drawing directly into it. For my purposes, is there any performance or other advantage to using the NSCustomImageRep intermediary?
The article makes it fairly clear that it's about resolution independence.
Apple's recommendation is to use +[NSImage imageWithSize:flipped:drawingHandler:]. That creates and manages the NSCustomImageRep under the hood.
https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/CapturingScreenContents/CapturingScreenContents.html#//apple_ref/doc/uid/TP40012302-CH10-SW32
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden