BitMiracle.LibTiff.Classic.Tiff.fetchShortPair C# (CSharp) Method

fetchShortPair() private method

private fetchShortPair ( TiffDirEntry dir ) : bool
dir TiffDirEntry
return bool
        private bool fetchShortPair(TiffDirEntry dir)
        {
            /*
            * Prevent overflowing arrays below by performing a sanity
            * check on tdir_count, this should never be greater than two.
            */
            if (dir.tdir_count > 2)
            {
                WarningExt(this, m_clientdata, m_name,
                    "unexpected count for field \"{0}\", {1}, expected 2; ignored",
                    FieldWithTag(dir.tdir_tag).Name, dir.tdir_count);
                return false;
            }

            switch (dir.tdir_type)
            {
                case TiffType.BYTE:
                case TiffType.SBYTE:
                    byte[] bytes = new byte[4];
                    return fetchByteArray(dir, bytes) && SetField(dir.tdir_tag, bytes[0], bytes[1]);

                case TiffType.SHORT:
                case TiffType.SSHORT:
                    short[] shorts = new short[2];
                    return fetchShortArray(dir, shorts) && SetField(dir.tdir_tag, shorts[0], shorts[1]);
            }

            return false;
        }
Tiff