views:

896

answers:

2

Is there a good way to read RAW image files (especially Canon CR2 and Adobe DNG files) as GDI+ bitmaps that is reasonably fast?

I found an example running under WPF that would read an image using any installed image codec and then display it in an image control. And I modified this example to create a GDI+ bitmap by writing the WPF image to a MemoryStream and creating the Bitmap from that. But this process is slow! Horribly slow! Opening a simple image takes around 10 seconds on my computer. This solution also requires references to the WPF assemblies and that doesn't feel right, especially not since I would like to run the code in an ASP.NET project.

There are programs that will do batch conversions of the images, but I would prefer converting the images dynamically when requested.

So, any suggestions?

+4  A: 

Disclaimer: I work at Atalasoft.

Our DotImage Photo Pro product can do this. If you want to try to do it yourself, look into wrapping the opensource DCRaw or look at how Paint.NET does it (I think there's a RAW plugin for it)

Lou Franco
DCraw: http://www.cybercom.net/~dcoffin/dcraw/
Jared Updike
+1  A: 

The DotImage Photo Pro component worked well, but I had a problem extracting the preview image from raw files using it. It is also outside my budget for this project.

But, I found the code for a RAW plugin for Paint.NET here and it was quite simple to adapt to my needs. The plugin runs the DCRaw executable usign Process.Start and reads its output from the StandardOutput stream. Quite simple and fast! :-)

Rune Grimstad
Does/can this read the EXIF data too?
Rowland Shaw
No, but there are other command line tools that will extract the exif. Try to google for "dcraw exif"
Rune Grimstad