Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chainable images? #31

Open
sixten opened this issue Aug 29, 2013 · 0 comments
Open

Chainable images? #31

sixten opened this issue Aug 29, 2013 · 0 comments

Comments

@sixten
Copy link
Contributor

sixten commented Aug 29, 2013

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant