简体   繁体   English

FreeImage.LoadFromStream对于CR2文件失败

[英]FreeImage.LoadFromStream fails for a CR2 file

The following code illustrates the problem I am faced with. 以下代码说明了我面临的问题。 If I load a CR2 file with 如果我加载一个CR2文件

var format = FREE_IMAGE_FORMAT.FIF_RAW;
retVal = FreeImage.LoadBitmap("AJ2A1447.cr2", ref format);

then I successfully load the RAW file. 然后我成功加载了RAW文件。 If I use something like 如果我使用类似

using (Stream stream = new FileStream("AJ2A1447.cr2", FileMode.Open, FileAccess.Read))
{
  var format = FREE_IMAGE_FORMAT.FIF_RAW;
  freeImageHandle = FreeImage.LoadFromStream(stream, ref format);
  if (freeImageHandle.IsNull)
  {
    throw new Exception("Unable to load image from stream");
  }

  retVal = FreeImage.GetBitmap(freeImageHandle);
}

then I am unsuccessful as freeImageHandle is null. 那么我不成功,因为freeImageHandle为null。 I use FileStream for a test, the real code will use a MemoryStream. 我使用FileStream进行测试,真正的代码将使用MemoryStream。

Any clue to why LoadFromStream fails? 任何提示导致LoadFromStream失败的线索?

there is number of RAW formats and I doubt if FREE_IMAGE_FORMAT.FIF_RAW knows how to decode CR2. RAW格式有很多,我怀疑FREE_IMAGE_FORMAT.FIF_RAW是否知道如何解码CR2。

http://en.wikipedia.org/wiki/Raw_image_format http://en.wikipedia.org/wiki/Raw_image_format

Try to use windows generated bitmap and jpg to see if your code works. 尝试使用Windows生成的位图和jpg查看您的代码是否有效。

FreeImage uses libRawLite to read Canon CR2 raw format. FreeImage使用libRawLite读取Canon CR2原始格式。 However, libRawLite does not support the sRAW CR2 files. 但是, libRawLite不支持sRAW CR2文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM