Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Image cache: Where is it and how do I refresh it?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Image cache: Where is it and how do I refresh it?



Ran into an unexpected problem last night while updating some pixel- level manipulation to be Intel-friendly. Spent a while searching Google and the list archives for ideas with no joy. Here's the situation:

1) I've got an NSView subclass whose drawRect: (among other things) draws part of an NSImage into (all of) itself, using NSImage>>drawInRect:fromRect:operation:fraction:.

2) I create a data buffer and load it with pixel data. I construct an NSBitmapImageRep using that buffer. I construct an NSImage and add the rep.

My NSView comes up on-screen and draws itself exactly as I expect. Then at some point the pixel buffer changes and setNeedsDisplay:YES is sent to the view. And it does redraw itself. But it's still showing the original image. I add some code before the setNeedsDisplay to dump the NSImage as a TIFF and that saved file has the updated image. NSImage>>representations returns an array with a single entry, and it's the one I created.

Sending setCacheMode:NSImageCacheNever to the image doesn't help.

If I remove the imagerep from the image and add a new one created from the same buffer it works.

The fact that the TIFF save works while a subsequent draw doesn't suggests to me that the view or window is doing the caching and recognizing that it's being asked to draw the same image but _not_ recognizing (understandably, I suppose) that the pixel data for the imagerep in that image has changed. Can anyone confirm where my stale cache is and suggest a way to refresh it?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.