Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to read and render 30+ (60 is the goal of course) 1.5-megapixel images per second? (even on iPhone 4)
    primarykey
    data
    text
    <p>I'm working on an image app where users can take photos and then "scrub" through them. The scrubber is a UISlider and as users move the thumb left to right, full-screen stored images display. There can be hundreds of images and I want the scrubbing experience to be lag-free. </p> <p>So far, here's what I've done. If you know that any of these are not the most efficient, please do tell. </p> <p>1) I store a low-res (about 40% quality) JPEG version of each photo in a separate DB table PhotoLowQuality. I hear I may be better off storing those as files and just putting filePath in the database? I do that with high-res images already in one branch of code, haven't tested performance difference yet.</p> <p>2) I now store full-res photos as 85% JPEGs, resized to about 1.5 megapixel (1500x1000) (since iPhone screen is not even 1 MP). I leave a bit of room for them to zoom in, but we don't need much for this type of app.</p> <p>3) When users scrub through photos, and it's fast (last photo was displayed less than 0.1 seconds ago, for example), I serve up the low-quality version first and kick off a timer that pulls the high-quality version of the photo say 0.1 seconds later. When users keep scrolling, they see low-version pics (you can barely tell the difference, though) and as soon as they slow down enough or stop, they see full-res pic near-instantly.</p> <p>4) I cache the photos with NSCache, but I'd really rather have 30+ FPS right away rather than after the first passthrough. Plus I noticed NSCache will sometimes crash the app due to not releasing memory in low-memory conditions fast enough, despite the documentation saying it does.</p> <p>To read the photos, I just use:</p> <pre><code>[UIImage imageWithContentsOfFile:photoCoreDataEntity.filename]; </code></pre> <p>This works pretty smooth on iPhone 5. Not so much on an iPhone 4. I don't have any multithreading yet - still trying to figure out the best way to fit it in. For example, if I put every image read request in NSOperation, I can cancel the previous operation when user scrubs to the next photo, but will it really cancel in the middle of reading from this or wait till it's done reading, thus kind of making the whole idea pointless? Maybe I need to read the bytes as steam on my own and check for Cancelled flag regularly...</p> <p>Any help to solve this problem would be appreciated! THANK YOU</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload