Reading RAW image files as GDI+ bitmaps
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! :-)
Edit:
The link to the plugin doesn't work anymore, but here is the code I used to extract the images. The following code extracts the jpg-preview stored in the raw file. If you want the full image you should remove the -e argument. But be aware that for some cameras you will get a ppm-image that GDI+ cannot read.
public Stream GetImageData(string inputFile, string dcRawExe)
{
var startInfo = new ProcessStartInfo(dcRawExe)
{
Arguments = "-c -e \"" + inputFile + "\"",
RedirectStandardOutput = true,
UseShellExecute = false
};
var process = Process.Start(startInfo);
var image = Image.FromStream(process.StandardOutput.BaseStream);
var memoryStream = new MemoryStream();
image.Save(memoryStream, ImageFormat.Png);
return memoryStream;
}
Also, you will need a copy of DCRaw. I used the DcrawMS.exe from this site: http://www.insflug.org/raw/Downloads/
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)