예제 #1
0
 public LJPEGPlain(TiffBinaryReader file, RawImage <ushort> img, bool DNGCompatible, bool UseBigTable) : base(file, img, DNGCompatible, UseBigTable)
 {
     CanonFlipDim      = false;
     CanonDoubleHeight = false;
     huff = new HuffmanTable[4] {
         new HuffmanTable(UseBigTable, DNGCompatible),
         new HuffmanTable(UseBigTable, DNGCompatible),
         new HuffmanTable(UseBigTable, DNGCompatible),
         new HuffmanTable(UseBigTable, DNGCompatible)
     };
 }
예제 #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;
        }
예제 #3
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;
        }
예제 #4
0
        public OpcodeMapPolynomial(TiffBinaryReader parameters, UInt32 param_max_bytes, ref int 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);
            mFirstPlane = parameters.ReadUInt32();
            mPlanes     = parameters.ReadUInt32();
            mRowPitch   = parameters.ReadUInt32();
            mColPitch   = parameters.ReadUInt32();
            if (mPlanes == 0)
            {
                throw new RawDecoderException("Zero planes");
            }
            if (mRowPitch == 0 || mColPitch == 0)
            {
                throw new RawDecoderException("Invalid Pitch");
            }

            mDegree    = parameters.ReadUInt32();
            bytes_used = 36;
            if (mDegree > 8)
            {
                throw new RawDecoderException("A polynomial with more than 8 degrees not allowed");
            }
            if (param_max_bytes < 36 + (mDegree * 8))
            {
                throw new RawDecoderException("Not enough data to read parameters, only " + param_max_bytes + " bytes left.");
            }
            for (UInt64 i = 0; i <= mDegree; i++)
            {
                parameters.BaseStream.Position = (long)(36 + 8 * i) + offset;
                mCoefficient[i] = Convert.ToDouble(parameters.ReadBytes(8));
            }
            bytes_used += (int)(8 * mDegree + 8);
            flags       = (int)Flags.MultiThreaded | (int)Flags.PureLookup;
        }