PhotoViewer icon indicating copy to clipboard operation
PhotoViewer copied to clipboard

No way to add pictures to the cache and a source?

Open Stokestack opened this issue 13 years ago • 3 comments

There doesn't seem to be a way to update a PhotoSource with a new photo; the internal array is immutable, so even subclassing doesn't help. For example: You have a downloaded collection of photos and then the user takes a new picture and your app uploads it. Obviously you don't want to re-download the picture just to add it to the cache; you want to add it directly from memory.

Adding this locally taken picture to the cache isn't practical right now for another reason: keyForURL (which generates the hashed key used to tag images in the cache) resides in EGOImageLoader.m. Shouldn't this at least be in the header file instead, so client apps can use it?

Or am I missing some existing ways in which images can be added directly to the cache and photo sources?

Stokestack avatar Mar 07 '11 01:03 Stokestack

An EGOPhoto object can take file URL's, you should store the image to disk after the user selects it, then pass the URL to the photo source. As far as being immutable after the photo view is presented, would you like a method to add a EGOPhoto to the photo source at anytime?

devindoty avatar Mar 07 '11 02:03 devindoty

Hi. Devin. Thanks for your response.

A file URL won't prevent the image from unnecessarily being re-downloaded from the Web when it's already in the cache, so I moved keyForURL into the EGOImageLoader header file; now I can call it from elsewhere to create hashed URLs for my locally acquired (and uploaded) files that will match subsequent attempts to retrieve them from a server with a URL. This works fine; I verified that newly taken pictures are pulled from the cache instead of re-downloaded on subsequent views.

And yes, I'd like a way to add a photo to a photo source at any time, so if I'm displaying the collection in a UI, the new photo gets added. In my copy of the code, I changed EGOPhotoSource's array into a mutable one and added an addPhoto: method. Now I need to figure out how to get existing views to reload from the PhotoSource. Does this sound reasonable?

Stokestack avatar Mar 07 '11 19:03 Stokestack

I have all of this working in my project. I made note of the changes to EGO (which were relatively minor) so I can contribute them back after I'm done testing.

Stokestack avatar Mar 24 '11 10:03 Stokestack