NSImageView: Large Image Display

I am working on a graphical browser for OS X. It is very similar to QuickLook: you select a folder, the application displays the first image in it, and you can use the arrow keys to quickly move to the next / previous image.

Now I am testing my application with RAW formats that are very large: for example, I have a .cr2 file that is almost 25MB. To load images of this type, NSImageView takes 5 to 10 seconds. I would like the transition from painting to the next to be as fast as possible. I see 2 options:

1) load the image gradually and display it as it loads (either in chunks or by gradually improving the resolution). Can this be done? How?

2) scale down the snapshots so the NSImageView can display them instantly (I'm not too worried about the resolution). How fast can an image be scaled?

Thank!

+3


source to share


2 answers


This 5-10 seconds is probably due to converting the RAW data to a format that can be displayed NSImageView

. Just reading 25MB from disk will impose latency, and processing all that data will add more. Whenever possible, you will want to avoid this conversion process.

CR2 files can contain small JPEG preview images, and it would be much faster to read a small thumbnail than convert a 25MB file. Webpage Canon RAW version 2 has a lot of information about the structure of CR2 files that should help you find thumbnail images. Another page, Extract Thumbnails from Camera RAW Files (.CR2 and .NEF) Using PHP , demonstrates how to extract thumbnails from your CR2 files.



If the thumbnails included in the file are not enough for your needs, you need to either let NSImageView

some other component convert the file for you, or write your own converter. The CR2 format information from the first link above should help you find the RAW data itself, and you could create a preview image faster than converting the whole thing by reading only every nth row of pixels (and then using only every nth pixel from the lines you are reading). See Section 4 in the section Retrieving Thumbnails ... a reference document for interpreting RAW data.

+2


source


You can preload previous and next images while this image is displayed. You just need to build a table of 3 NSImage

, shift them as needed and load a new one. So that your images are almost always loaded before showing them. Of course, this won't work if you are pressing keys very quickly. You can also preload any number of images. Remember it NSImage

has a caching mechanism inside.



+1


source







All Articles