コード例 #1
0
        /***************** OpcodeTrimBounds   ****************/

        public OpcodeTrimBounds(TiffBinaryReader parameters, UInt32 param_max_bytes, ref Int32 bytes_used)
        {
            if (param_max_bytes < 16)
            {
                throw new RawDecoderException("Not enough data to read parameters, only " + param_max_bytes + " bytes left.");
            }
            mTop       = parameters.ReadUInt16();
            mLeft      = parameters.ReadUInt16();
            mBottom    = parameters.ReadUInt16();
            mRight     = parameters.ReadUInt16();
            bytes_used = 16;
        }
コード例 #2
0
        /***************** OpcodeMapTable   ****************/

        public OpcodeMapTable(TiffBinaryReader parameters, ulong param_max_bytes, ref Int32 bytes_used, uint offset)
        {
            if (param_max_bytes < 36)
            {
                throw new RawDecoderException("Not enough data to read parameters, only " + param_max_bytes + " bytes left.");
            }
            uint h1 = parameters.ReadUInt32();
            uint w1 = parameters.ReadUInt32();
            uint h2 = parameters.ReadUInt32();
            uint w2 = parameters.ReadUInt32();

            aoi.SetAbsolute(w1, h1, w2, h2);
            firstPlane = parameters.ReadUInt32();
            planes     = parameters.ReadUInt32();
            rowPitch   = parameters.ReadUInt32();
            colPitch   = parameters.ReadUInt32();
            if (planes == 0)
            {
                throw new RawDecoderException("Zero planes");
            }
            if (rowPitch == 0 || colPitch == 0)
            {
                throw new RawDecoderException("Invalid Pitch");
            }

            int tablesize = (int)parameters.ReadUInt32();

            bytes_used = 36;

            if (tablesize <= 0)
            {
                throw new RawDecoderException("Table size must be positive");
            }
            if (tablesize > 65536)
            {
                throw new RawDecoderException("A map with more than 65536 entries not allowed");
            }

            if (param_max_bytes < 36 + ((UInt64)tablesize * 2))
            {
                throw new RawDecoderException("Not enough data to read parameters, only " + param_max_bytes + " bytes left.");
            }

            for (int i = 0; i <= 65535; i++)
            {
                int location = Math.Min(tablesize - 1, i);
                parameters.BaseStream.Position = 36 + 2 * location + offset;
                Lookup[i] = parameters.ReadUInt16();
            }

            bytes_used += tablesize * 2;
            flags       = (int)Flags.MultiThreaded | (int)Flags.PureLookup;
        }