Here's what I'd like to be able to do:
- Have a model object that has an image URL (a person's avatar, say).
- When that object is loaded, begins loading its image at native size (
OGCachedImage, most likely).
- As the various UIs need particular sizes of the image, create new
OGScaledImage instances from that base image, at the specific resolution(s) required.
Now, the OGImage subclasses to have initializers that take __OGImage objects, and apply their specific operations to them. (Those should probably take UIImage, because there doesn't seem to be any—public—way to get an __OGImage from an OGImage.) However, it may well be the case that the scaled image is created from the base image while the resource is still being loaded from the web, in which case there is no concrete image data associated with the base OGImage yet (or different, if it was created with a placeholder).
What I'm imagining is something like:
@interface OGImage (ScaledChaining)
- (OGScaledImage *)scaledImageAtSize:(CGSize)size;
@end
The new instance would become an observer of the original instance, and when the base instance's image changes, the new instance would (re)apply its processing and set a new value for its own image and scaledImage.
It has been pointed out to me that two OGImage objects loading the same URL will piggyback off of the same network request, so this effect could be approximated by creating the new instance with the base instance's URL, like so:
OGScaledImage *scaled = [[OGScaledImage alloc]
initWithURL:modelObject.someImage.url size:size key:nil];
So maybe I'm over-complicating things?
Here's what I'd like to be able to do:
OGCachedImage, most likely).OGScaledImageinstances from that base image, at the specific resolution(s) required.Now, the
OGImagesubclasses to have initializers that take__OGImageobjects, and apply their specific operations to them. (Those should probably takeUIImage, because there doesn't seem to be any—public—way to get an__OGImagefrom anOGImage.) However, it may well be the case that the scaled image is created from the base image while the resource is still being loaded from the web, in which case there is no concrete image data associated with the baseOGImageyet (or different, if it was created with a placeholder).What I'm imagining is something like:
The new instance would become an observer of the original instance, and when the base instance's
imagechanges, the new instance would (re)apply its processing and set a new value for its ownimageandscaledImage.It has been pointed out to me that two
OGImageobjects loading the same URL will piggyback off of the same network request, so this effect could be approximated by creating the new instance with the base instance's URL, like so:So maybe I'm over-complicating things?