سؤال

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?

هل كانت مفيدة؟

المحلول 2

FreeImage uses libRawLite to read Canon CR2 raw format. However, libRawLite does not support the sRAW CR2 files.

نصائح أخرى

there is number of RAW formats and I doubt if FREE_IMAGE_FORMAT.FIF_RAW knows how to decode CR2.

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

Try to use windows generated bitmap and jpg to see if your code works.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top