Re: Generic Bitmap to NSImage
Re: Generic Bitmap to NSImage
- Subject: Re: Generic Bitmap to NSImage
- From: Graham Cox <email@hidden>
- Date: Fri, 26 Jun 2015 09:29:17 +1000
> On 26 Jun 2015, at 9:10 am, Raglan T. Tiger <email@hidden> wrote:
>
> I have a list of generic bitmaps that are to be transformed to NSImages. The list can be long, I haven limits on it.
>
> Here is the code I use to populate an NSMenu that gets set into an NSPopUpButton.
>
> I need to speed this process up ... any suggestions?
Instead of creating a CGBitmapContext to wrap your pixel buffer, then turning it into a CGImage, then copying it to an NSImage, why not create a NSBitmapImageRep directly wrapping the original buffer? Then it can be added to an NSImage as a rep without any copying being necessary at any point. The slowness here (which you imply is a problem) is very likely due to the fact that you are having to copy each bitmap twice (once when you create the CGImage, the second time when you blit that into the NSImage).
—Graham
_______________________________________________
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