在C#中读取原始图像文件 [英] Reading raw image files in c#

查看:165
本文介绍了在C#中读取原始图像文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在未安装编解码器的情况下解码/打开.CR2或.NEF和.ARW之类的原始图像文件,例如lightroom打开原始文件?我的代码如下:

How do i decode/open raw image files like .CR2 or .NEF and .ARW without having the codec installed, something like lightroom open raw files ? My code look like this:

if (fe == "CR2" | fe == "NEF" | fe == "ARW" )
{
    BitmapDecoder bmpDec = BitmapDecoder.Create(new Uri(op.FileName), BitmapCreateOptions.DelayCreation, BitmapCacheOption.None);

    BitmapSource bsource = bmpDec.Frames[0];
    info_box.Content = fe;
    imgControl.Source = bsource;
}

此功能仅适用于安装了原始编解码器且不安装可以使用ARW格式。

This work only with the raw codecs installed and dont work with ARW format.

推荐答案

如果您没有安装编解码器,那么您必须读取原始图像数据并将其转换为位图或您可以读取的其他格式。为此,您需要一份格式规范的副本,以便您可以编写读取二进制数据的代码。

If you don't have a codec installed, then you'll have to read the raw image data and convert it to a bitmap or other format that you can read. In order to do that, you need a copy of the format specification so that you can write code that reads the binary data.

我强烈建议您使用编解码器或查找有人编写的已经处理了转换的代码。但是,如果您真的想尝试编写图像格式转换代码,那么您的首要任务就是获取格式规范。

I strongly recommend getting a codec, or finding code that somebody has written that already handles the conversion. But if you really want to try your hand at writing image format conversion code, your first order of business is to get the format specification.

在[CR2]上进行快速的Google搜索图片格式]揭示了此佳能CR2规范。说实话,我不知道这有多精确,但是看起来很合理。在搜索引擎上花一点时间,可能会发现其他格式的相似文档。

A quick Google search on [CR2 image format] reveals this Canon CR2 Specification. Truthfully, I don't know how accurate that is, but it looks reasonable. A little time with a search engine will probably reveal similar documents for the other formats.

请注意:编写这些转换可能是一项非常困难的任务。同样,我建议您找到一些可以利用的现有代码。

Be forewarned: writing these conversions can be a very difficult task. Again, I recommend that you find some existing code that you can leverage.

这篇关于在C#中读取原始图像文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆