Re: NSImage from bitmap - then delete bitmap
Re: NSImage from bitmap - then delete bitmap
- Subject: Re: NSImage from bitmap - then delete bitmap
- From: Graham Cox <email@hidden>
- Date: Sat, 23 Jul 2016 00:08:03 +1000
> On 22 Jul 2016, at 11:53 PM, Trygve Inda <email@hidden> wrote:
>
> How can I draw the NSImageRep directly into a window?
-[NSImageRep drawInRect:fromRect:operation:fraction:respectFlipped:hints:];
i.e. same as NSImage.
>
> Also, the main pixel buffer is updated slowly (it takes a long time to
> draw). So once the worker thread is done, it needs to pass off those pixels
> to the main thread to be drawn.
>
> Currently it blocks at this point, but I need to avoid that.
It’s not really clear why this needs to be avoided. The time to draw the pixels should be a few milliseconds, a small fraction of the time your thread needs to run, even at its fastest.
> Since it can't
> block,
> the pixels need to be copied to the main thread because as soon as
> they get handed to the main thread, the worker thread will erase the
> original pixel buffer to start drawing a new image into it.
Copying the image is likely to be just as slow/fast as drawing it, so the copy isn’t going to help speed up your thread. Both operations have to iterate over the pixels; drawing *IS* copying.
> The copy needs to exist long enough to be drawn into a window by the main
> thread and can then be released.
Understood, but you may as well keep it around until the next version of the image is passed across - the previous one will be released at the same time when setting the property.
—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