GregEakin / PhotoDebug

Read the raw CR2 files from my CANON cameras

Home Page:http://gdbtech.info

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Photo Debug

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.

JPEG: Still Image Data Compression Standard

Information:

Links:

Sample Code

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);
}

Author

🔥 Greg Eakin

About

Read the raw CR2 files from my CANON cameras

http://gdbtech.info


Languages

Language:C# 100.0%