/* DNG Images are assumed to be decodable unless explicitly set so */ protected override void checkSupportInternal(CameraMetaData meta) { // We set this, since DNG's are not explicitly added. failOnUnknown = false; var t = mRootIFD.getEntryRecursive(TagType.MAKE); var t2 = mRootIFD.getEntryRecursive(TagType.MODEL); if (!(t != null && t2 != null)) { // Check "Unique Camera Model" instead, uses this for both make + model. var t3 = mRootIFD.getEntryRecursive(TagType.UNIQUECAMERAMODEL); if (t3 != null) { string unique = t3.dataAsString; this.checkCameraSupported(meta, unique, unique, "dng"); return; } else { // If we don't have make/model we cannot tell, but still assume yes. return; } } List <IFD> data = mRootIFD.getIFDsWithTag(TagType.MODEL); string make = data[0].getEntry(TagType.MAKE).dataAsString; string model = data[0].getEntry(TagType.MODEL).dataAsString; this.checkCameraSupported(meta, make, model, "dng"); }
public DngDecoder(IFD rootIFD, ref TIFFBinaryReader file) : base(ref file) { mRootIFD = (rootIFD); List <IFD> data = mRootIFD.getIFDsWithTag(TagType.DNGVERSION); var v = data[0].getEntry(TagType.DNGVERSION).data; if ((byte)v[0] != 1) { throw new RawDecoderException("Not a supported DNG image format: " + (int)v[0] + (int)v[1] + (int)v[2] + (int)v[3]); } // if (v[1] > 4) // throw new RawDecoderException("Not a supported DNG image format: v%u.%u.%u.%u", (int)v[0], (int)v[1], (int)v[2], (int)v[3]); if (((byte)v[0] <= 1) && ((byte)v[1] < 1)) // Prior to v1.1.xxx fix LJPEG encoding bug { mFixLjpeg = true; } else { mFixLjpeg = false; } }
public RawDecoder getDecoder() { if (rootIFD == null) { parseData(); } List <IFD> potentials = new List <IFD>(); potentials = rootIFD.getIFDsWithTag(TagType.DNGVERSION); /* Copy, so we can pass it on and not have it destroyed with ourselves */ IFD root = rootIFD; if (potentials.Count != 0) { // We have a dng image entry IFD t = potentials[0]; t.tags.TryGetValue(TagType.DNGVERSION, out Tag tag); object[] c = tag.data; if (Convert.ToInt32(c[0]) > 1) { throw new TiffParserException("DNG version too new."); } rootIFD = null; return(new DngDecoder(root, ref reader)); } potentials = rootIFD.getIFDsWithTag(TagType.MAKE); if (potentials.Count > 0) { // We have make entry foreach (IFD i in potentials) { i.tags.TryGetValue(TagType.MAKE, out Tag tag); string make = tag.dataAsString; make = make.Trim(); //remove trailing \0 if any string model = ""; i.tags.TryGetValue(TagType.MODEL, out Tag tagModel); if (tagModel != null) { model = tagModel.dataAsString; model = make.Trim(); } switch (make) { /* * case "Canon": * rootIFD = null; * return new Cr2Decoder(root, reader); * case "FUJIFILM": * rootIFD = null; * return new RafDecoder(root, reader);*/ case "NIKON CORPORATION": case "NIKON": rootIFD = null; return(new NefDecoder(ref root, reader)); /* * case "OLYMPUS IMAGING CORP.": * case "OLYMPUS CORPORATION": * case "OLYMPUS OPTICAL CO.,LTD": * rootIFD = null; * return new OrfDecoder(root, reader); * case "SONY": * rootIFD = null; * return new ArwDecoder(root, reader); * case "PENTAX Corporation": * case "RICOH IMAGING COMPANY, LTD.": * case "PENTAX": * rootIFD = null; * return new PefDecoder(root, reader); * case "Panasonic": * case "LEICA": * rootIFD = null; * return new Rw2Decoder(root, reader); * case "SAMSUNG": * rootIFD = null; * return new SrwDecoder(root, reader); * case "Mamiya-OP Co.,Ltd.": * rootIFD = null; * return new MefDecoder(root, reader); * case "Kodak": * rootIFD = null; * if (String.Compare(model, "DCS560C") == 0) * return new Cr2Decoder(root, reader); * else * return new DcrDecoder(root, reader); * case "KODAK": * rootIFD = null; * return new DcsDecoder(root, reader); * case "EASTMAN KODAK COMPANY": * rootIFD = null; * return new KdcDecoder(root, reader); * case "SEIKO EPSON CORP.": * rootIFD = null; * return new ErfDecoder(root, reader); * case "Hasselblad": * rootIFD = null; * return new ThreefrDecoder(root, reader); * case "Leaf": * rootIFD = null; * return new MosDecoder(root, reader); * case "Phase One A/S": * rootIFD = null; * return new MosDecoder(root, reader); */ } } /* * // Last ditch effort to identify Leaf cameras that don't have a Tiff Make set * potentials = rootIFD.getIFDsWithTag(TagType.SOFTWARE); * if (potentials.Count > 0) * { * potentials[0].tags.TryGetValue((ushort)TagType.SOFTWARE, out Tag tag); * string software = tag.dataAsString; * software = software.Trim(); * if (String.Compare(software, "Camera Library") == 0) * { * rootIFD = null; * return new MosDecoder(root, reader); * } * }*/ } //default as astandard tiff rootIFD = null; return(new TiffDecoder(root, ref reader)); //TODO add detection of Tiff throw new TiffParserException("No decoder found. Sorry."); }