0

I tried different examples and did google also but could not find any working c# solution.. also found some codes in different languages but I'm unable to convert them to c# please help...

I've tried this:- Convert .arw Sony photo to .raw file

Also found dcraw source code but could not find anything related to ARW...

Image.FromFile and Image.FromStream methods was also giving "Parameter is not valid."

Just now I tried this and got "The image cannot be decoded. The image header might be corrupted."

BitmapDecoder bmpDec = BitmapDecoder.Create(new Uri(file), BitmapCreateOptions.DelayCreation, BitmapCacheOption.None);
BitmapEncoder bmpEnc = new BmpBitmapEncoder();
bmpEnc.Frames.Add(bmpDec.Frames[0]);
Stream ms = new MemoryStream();
bmpEnc.Save(ms);
Image srcImage = Bitmap.FromStream(ms);

Please help me to convert arw raw files to jpegs. I wanna do it with or without codecs. I don't know how to use sony's code so please help me with that. I just want to make this program work

Misha Zaslavsky
  • 8,414
  • 11
  • 70
  • 116
  • Is this for a Winforms app, WPF app, ASP.Net website, Windows Phone app, or something else? – Rowland Shaw Nov 08 '13 at 16:57
  • well does it matter really..? I want to use it in desktop app as well as in asp.net –  Nov 08 '13 at 17:03
  • WPF has support for additional CODECs (when installed) when using [`Image.FromFile()`](http://msdn.microsoft.com/en-us/library/system.drawing.image.fromfile.aspx); see also: [Extending the list of supported image formats in GDI+](http://stackoverflow.com/q/455018/50447) – Rowland Shaw Nov 08 '13 at 17:30
  • possible duplicate of [Sony's ARW raw file to jpg using c#](http://stackoverflow.com/questions/19854656/sonys-arw-raw-file-to-jpg-using-c-sharp) – Hans Passant Nov 08 '13 at 19:10
  • I've tried in WPF, Image.FromFile was giving "Out Of Memory". File size is 20mb, system is i5 with 8GB ram –  Nov 09 '13 at 01:59

2 Answers2

1

"The image cannot be decoded. The image header might be corrupted."

I got the same thing if the C# applications platform was "Any CPU" or "x86". Setting the platform to "x64" fixed it for me. I also got the same behaviour when using the the codec from native C++ and WIC over COM. I.e. it wouldn't work if called from a 32bit application but it did for a 64bit application.

Sorry for posting on an old thread but there isn't much information available about this topic.

Adam
  • 11
  • 1
0

I've found how to do it. Simply install the Sony Codec downloadable here https://esupport.sony.com/swu/4025/US/

And then the BitmapDecoder will work properly.

Michele
  • 1
  • 1