This is a .NET C# project that reads the raw CR2 files from CANON cameras.
For the image compression, this book was helpful: JPEG: Still Image Data Compression Standard by Pennebaker, William B., Mitchell, Joan L.
- ExifTool by Phil Harvey, Read, Write and Edit Meta Information!
- The Canon RAW (CRW) File Format
- ExifPro is an image browser application
- Understanding What is stored in a Canon RAW .CR2 file, How and Why
- EXIF MakerNote of Canon
- JPEG Snoop, File Decoding Utility
- Raw Digger
- FastRawViewer is the only WYSIWYG RAW viewer
- Community Edition of Visual Studio (Free)
- Git Extensions (Free)
- ReSharper, Extensions for .NET Developers
- Amazon
- Google Books
Here's sample test code to verify the raw image size, from my Canon 7D:
- Sensor Width: 5360 = 1340 * 4 = 2 * 1728 + 1904
- Sensor Height: 3516
- Sensor Precision: 14
using (var fileStream = File.Open(FileName, FileMode.Open, FileAccess.Read))
using (var binaryReader = new BinaryReader(fileStream))
{
var rawImage = new RawImage(binaryReader);
var directory = rawImage.Directories.Last();
var data = directory.Entries.Single(e => e.TagId == 0x0111).ValuePointer;
var length = directory.Entries.Single(e => e.TagId == 0x0117).ValuePointer;
var strips = directory.Entries.Single(e => e.TagId == 0xC640 && e.TagType == 3).ValuePointer;
binaryReader.BaseStream.Seek(strips, SeekOrigin.Begin);
var x = binaryReader.ReadUInt16();
var y = binaryReader.ReadUInt16();
var z = binaryReader.ReadUInt16();
Assert.AreEqual(2, x);
Assert.AreEqual(1728, y);
Assert.AreEqual(1904, z);
binaryReader.BaseStream.Seek(data, SeekOrigin.Begin);
var startOfImage = new StartOfImage(binaryReader, data, length);
var lossless = startOfImage.StartOfFrame;
Assert.AreEqual(14, lossless.Precision);
Assert.AreEqual(4, lossless.Components.Length);
Assert.AreEqual(1340, lossless.SamplesPerLine);
Assert.AreEqual(3516, lossless.ScanLines);
}