Re: NSImage from bitmap - then delete bitmap
Re: NSImage from bitmap - then delete bitmap
- Subject: Re: NSImage from bitmap - then delete bitmap
- From: Ken Thomases <email@hidden>
- Date: Fri, 22 Jul 2016 01:29:36 -0500
On Jul 22, 2016, at 1:08 AM, Trygve Inda <email@hidden> wrote:
>
>> But that’s not a great way to do this. You’ve made an image, you’ve encoded it
>> as TIFF data, then you’ve made a new image, which has decoded the TIFF data to
>> make a new image rep/bitmap.
>>
>> You could just add the representation directly to a new NSImage (warning:
>> typed into Mail, check method names):
>>
>> NSImage* myImage = [[NSImage alloc] initWithSize:NSMakeSize(width,height)];
>>
>> [myImage addRepresentation:theBitmapIMadeFirst];
>>
>> [theBitmapIMadeFirst release]; // because NSImage retained it
>
>
> I don't think the second part will work because of my workflow:
>
> At Launch: Create pixel buffer that is 1000 x 1000 pixels
>
> Looping thread
> 1. Fill pixel buffer with pixels based on some algorithm
> 2. create an NSImage with these pixels
> 3. pass it to the main thread to be drawn in a window
> Restart the loop with a slightly modified algorithm
>
> If calling this:
> [myImage addRepresentation:theBitmapIMadeFirst];
>
> Only causes the NSImage to retain it, then when I change the pixels in the
> bitmap, they get changed in the NSImage.
>
> I need the NSImage to keep the pixels as they existed when I created it.
Hint: NSBitmapImageRep conforms to the NSCopying protocol.
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