예제 #1
0
        public TiffIFD(ref byte[] content, uint adressOffset, bool ISBigEndian)
        {
            uint ifdEnd;

            if (ISBigEndian)
            {
                tagCount      = BitConverter.ToUInt16(new byte[] { content[adressOffset + 1], content[adressOffset] }, 0);
                ifdEnd        = adressOffset + (uint)(tagCount * 12 + 6);
                NextIFDOffset = BitConverter.ToUInt32(new byte[] { content[ifdEnd - 1], content[ifdEnd - 2], content[ifdEnd - 3], content[ifdEnd - 4] }, 0);
            }
            else
            {
                tagCount      = BitConverter.ToUInt16(new byte[] { content[adressOffset], content[adressOffset + 1] }, 0);
                ifdEnd        = adressOffset + (uint)(tagCount * 12 + 6);
                NextIFDOffset = BitConverter.ToUInt32(new byte[] { content[ifdEnd - 4], content[ifdEnd - 3], content[ifdEnd - 2], content[ifdEnd - 1] }, 0);
            }
            tiffTags = new TiffTag[tagCount];


            for (int miind = 0; miind < tagCount; miind++)
            {
                byte[] bArray = new byte[12];
                tiffTags[miind] = new TiffTag(ref content, (uint)(adressOffset + 2 + miind * 12), ISBigEndian);
            }
            var tIFD = (from t in tiffTags where t.TagID == 330 select t).FirstOrDefault();

            HasSubIFD = tIFD != null && tIFD.TagID == 330;
            if (HasSubIFD)
            {
                SubIFDS = new TiffIFD[tIFD.DataCount];
            }
        }
예제 #2
0
        private TiffIFD[] FillTifID(uint adressIFD)
        {
            bool           moreIFD  = true;
            List <TiffIFD> tiffIFDs = new List <TiffIFD>();

            do
            {
                TiffIFD ifd = FillIFD(adressIFD);
                tiffIFDs.Add(ifd);
                if (ifd.NextIFDOffset == 0)
                {
                    moreIFD = false;
                }
                else
                {
                    adressIFD = ifd.NextIFDOffset;
                }
            } while (moreIFD);
            return(tiffIFDs.ToArray());
        }
예제 #3
0
        private TiffIFD FillIFD(uint adressIFD)
        {
            ushort tagCount;

            if (ISBigEndian)
            {
                tagCount = BitConverter.ToUInt16(new byte[] { _content[adressIFD + 1], _content[adressIFD] }, 0);
            }
            else
            {
                tagCount = BitConverter.ToUInt16(new byte[] { _content[adressIFD], _content[adressIFD + 1] }, 0);
            }

            var ifd = new TiffIFD(ref _content, adressIFD, ISBigEndian);
            //var isDNG = (from tt in ifd.tiffTags where tt.TagID == 50706 select tt).FirstOrDefault().TagID != 50706;
            var makeValue = (from tt in ifd.tiffTags where tt.TagID == 271 select tt.TagValue).FirstOrDefault();

            if (makeValue != null)
            {
                switch (makeValue.ToString())
                {
                case string a when a.ToUpper().Contains("NIKON"):
                    _rawType = RawType.NEF;

                    break;

                case string a when a.ToUpper().Contains("SONY"):
                    _rawType = RawType.ARW;

                    break;

                case string a when a.ToUpper().Contains("CANON"):
                    _rawType = RawType.CR2;

                    break;

                case string a when a.ToUpper().Contains("HASSELBLAD"):
                    _rawType = RawType.Hasselblad;

                    break;
                }
            }
            //if (isDNG)
            //    _rawType = RawType.DNG;
            if (ifd.HasSubIFD)
            {
                var            tIFD     = (from t in ifd.tiffTags where t.TagID == 330 select t).FirstOrDefault();
                var            Model    = (from t in ifd.tiffTags where t.TagID == 272 select t.TagValue).FirstOrDefault().ToString();
                List <TiffIFD> lstsubID = new List <TiffIFD>();
                for (int miind = 0; miind < tIFD.DataCount; miind++)
                {
                    uint SubifdOffset;
                    if (ISBigEndian)
                    {
                        SubifdOffset = BitConverter.ToUInt32(new byte[] { _content[(4 * miind) + tIFD.DataOffset + 3], _content[(4 * miind) + tIFD.DataOffset + 2], _content[(4 * miind) + tIFD.DataOffset + 1], _content[(4 * miind) + tIFD.DataOffset] }, 0);
                    }
                    else
                    {
                        SubifdOffset = BitConverter.ToUInt32(new byte[] { _content[(4 * miind) + tIFD.DataOffset], _content[(4 * miind) + tIFD.DataOffset + 1], _content[(4 * miind) + tIFD.DataOffset + 2], _content[(4 * miind) + tIFD.DataOffset + 3] }, 0);
                    }

                    if (_rawType == RawType.ARW || Model.ToUpper().Contains("HASSELBLAD X1D\0"))
                    {
                        SubifdOffset = tIFD.DataOffset;
                    }
                    lstsubID.Add(FillIFD(SubifdOffset));
                }
                ifd.SubIFDS = lstsubID.ToArray();
            }
            return(ifd);
        }