2

The following code illustrates the problem I am faced with. If I load a CR2 file with

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

then I successfully load the RAW file. 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. I use FileStream for a test, the real code will use a MemoryStream.

Any clue to why LoadFromStream fails?

4

2 回答 2

1

有多种 RAW 格式,我怀疑 FREE_IMAGE_FORMAT.FIF_RAW 是否知道如何解码 CR2。

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

尝试使用 windows 生成的位图和 jpg 来查看您的代码是否有效。

于 2013-08-10T10:14:47.050 回答
0

FreeImage 用于libRawLite读取Canon CR2原始格式。但是,libRawLite不支持sRAWCR2 文件。

于 2013-08-11T16:30:19.473 回答