Re: NSCustomImageRep and NSImage setSize
Re: NSCustomImageRep and NSImage setSize
- Subject: Re: NSCustomImageRep and NSImage setSize
- From: Ken Ferry <email@hidden>
- Date: Mon, 11 Nov 2013 13:19:05 -0800
Hi Mathew,
If you can repro that in a test app, please file it.
The cache is used or tossed at _draw_ time, and it's based on whether the
number of pixels in the area to be covered matches the number of pixels in
the cache.
The -size of the NSImage has only an indirect effect on anything, in that
something might choose to draw the NSImage into a larger area based on that
size. The -size is really just metadata regarding how much space the image
might "prefer" to be drawn into.
FYI - generally, an NSImage should be thought of as immutable after it's
been (say) added to an NSImageView. It's not thread safe to change the size
of an NSImage while something else is using it on another thread, and you
have no idea if something else is using it on another thread once you've
vended it out to your app at large. The alternative is to copy the image
and change the size of the copy. This is cheap - the pixels are not copied,
just the shell NSImage structure.
For more info, please see a talk I gave, <
https://deimos.apple.com/WebObjects/Core.woa/BrowsePrivately/adc.apple.com.2233538716.02233538722.2238039498?i=1820509221
>.
-ken
On Fri, Nov 8, 2013 at 8:48 AM, Graham Cox <email@hidden> wrote:
> Hi Mathew,
>
> I think you need to set it to NSImageCacheNever. This turns off all of the
> internal caching mechanism, so your rep, if it’s the only rep in the image,
> will always be the one to draw. It’ll only be as pixellated as your
> implementation allows, which should be not at all, right?
>
> —Graham
>
>
> On 8 Nov 2013, at 4:46 pm, Mathew Eis <email@hidden> wrote:
>
> > Hi Graham,
> >
> > Thanks for the reply… That’s more or less the crux of the issue; I can’t
> figure out how to make the rep "resolution independent”.
> >
> > If I draw it once at, say, 100x100, then I draw it again at 200x200, the
> second will be pixellated because the NSImage is using a cached (bitmap?)
> copy of it… If I drew it the first time at 200x200, the cached version
> has the correct resolution - but it isn’t truly resolution independent
> because it still seems to be caching a bitmap somewhere.
> >
> > Regards,
> >
> > -Mathew Eis
>
>
> _______________________________________________
>
> 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
>
_______________________________________________
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