Two things I'm struggling with:
- I'm trying to test for equality between two NSImage objects, in terms of the underlying image data used by each one. Unfortunately, NSImage's implementation of isEqual: only tests for pointer equality, as inherited from NSObject.
The only way I can see of doing this is calling TIFFRepresentation on both images, and comparing the NSData objects. However, since this involves calculating new data (much larger than that used to create the NSImage in the first place!), it seems like an expensive way of testing for equality.
- I'd like to (very roughly) calculate the memory used by the image. I'm keeping a cache of images, and I want to limit the size of the cache by memory used, rather than number of images.
I realise these things are tricky because of the magic that NSImage works behind the scenes, but if anyone has any suggestions it would be appreciated!
All images will be bitmaps.
- I'm trying to test for equality between two NSImage objects, in terms of the underlying image data used by each one. Unfortunately, NSImage's implementation of isEqual: only tests for pointer equality, as inherited from NSObject.
The only way I can see of doing this is calling TIFFRepresentation on both images, and comparing the NSData objects. However, since this involves calculating new data (much larger than that used to create the NSImage in the first place!), it seems like an expensive way of testing for equality.
- I'd like to (very roughly) calculate the memory used by the image. I'm keeping a cache of images, and I want to limit the size of the cache by memory used, rather than number of images.
I realise these things are tricky because of the magic that NSImage works behind the scenes, but if anyone has any suggestions it would be appreciated!
All images will be bitmaps.