Esempio n. 1
0
        // Set state to appear as if a
        // tile has just been read in.
        static bool TIFFStartTile(TIFF tif, uint tile)
        {
            TIFFDirectory td = tif.tif_dir;

            if ((tif.tif_flags & TIF_FLAGS.TIFF_CODERSETUP) == 0)
            {
                if (!tif.tif_setupdecode(tif))
                {
                    return(false);
                }
                tif.tif_flags |= TIF_FLAGS.TIFF_CODERSETUP;
            }

            tif.tif_curtile = tile;
            tif.tif_row     = (tile % TIFFhowmany(td.td_imagewidth, td.td_tilewidth)) * td.td_tilelength;
            tif.tif_col     = (tile % TIFFhowmany(td.td_imagelength, td.td_tilelength)) * td.td_tilewidth;
            if ((tif.tif_flags & TIF_FLAGS.TIFF_NOREADRAW) == TIF_FLAGS.TIFF_NOREADRAW)
            {
                tif.tif_rawdata = null;               // ?????
                tif.tif_rawcp   = 0;
                tif.tif_rawcc   = 0;
            }
            else
            {
                tif.tif_rawcp = 0;               //was tif.tif_rawdata;
                tif.tif_rawcc = td.td_stripbytecount[tile];
            }

            return(tif.tif_predecode(tif, (ushort)(tile / td.td_stripsperimage)));
        }
Esempio n. 2
0
        // Set state to appear as if a
        // strip has just been read in.
        static bool TIFFStartStrip(TIFF tif, uint strip)
        {
            TIFFDirectory td = tif.tif_dir;

            if ((tif.tif_flags & TIF_FLAGS.TIFF_CODERSETUP) == 0)
            {
                if (!tif.tif_setupdecode(tif))
                {
                    return(false);
                }
                tif.tif_flags |= TIF_FLAGS.TIFF_CODERSETUP;
            }
            tif.tif_curstrip = strip;
            tif.tif_row      = (strip % td.td_stripsperimage) * td.td_rowsperstrip;
            if ((tif.tif_flags & TIF_FLAGS.TIFF_NOREADRAW) == TIF_FLAGS.TIFF_NOREADRAW)
            {
                tif.tif_rawdata = null;               // ?????
                tif.tif_rawcp   = 0;
                tif.tif_rawcc   = 0;
            }
            else
            {
                tif.tif_rawcp = 0;               //was tif.tif_rawdata;
                tif.tif_rawcc = td.td_stripbytecount[strip];
            }
            return(tif.tif_predecode(tif, (ushort)(strip / td.td_stripsperimage)));
        }
Esempio n. 3
0
        // Setup state for decoding a strip.
        static bool ZIPPreDecode(TIFF tif, ushort sampleNumber)
        {
            ZIPState sp = tif.tif_data as ZIPState;

#if DEBUG
            if (sp == null)
            {
                throw new Exception("sp==null");
            }
#endif

            if ((sp.state & ZSTATE.INIT_DECODE) != ZSTATE.INIT_DECODE)
            {
                tif.tif_setupdecode(tif);
            }

            sp.stream.in_buf   = tif.tif_rawdata;
            sp.stream.next_in  = 0;
            sp.stream.avail_in = tif.tif_rawcc;
            return(zlib.inflateReset(sp.stream) == zlib.Z_OK);
        }
Esempio n. 4
0
        // Set state to appear as if a
        // tile has just been read in.
        static bool TIFFStartTile(TIFF tif, uint tile)
        {
            TIFFDirectory td=tif.tif_dir;

            if((tif.tif_flags&TIF_FLAGS.TIFF_CODERSETUP)==0)
            {
                if(!tif.tif_setupdecode(tif)) return false;
                tif.tif_flags|=TIF_FLAGS.TIFF_CODERSETUP;
            }

            tif.tif_curtile=tile;
            tif.tif_row=(tile%TIFFhowmany(td.td_imagewidth, td.td_tilewidth))*td.td_tilelength;
            tif.tif_col=(tile%TIFFhowmany(td.td_imagelength, td.td_tilelength))*td.td_tilewidth;
            if((tif.tif_flags&TIF_FLAGS.TIFF_NOREADRAW)==TIF_FLAGS.TIFF_NOREADRAW)
            {
                tif.tif_rawdata=null; // ?????
                tif.tif_rawcp=0;
                tif.tif_rawcc=0;
            }
            else
            {
                tif.tif_rawcp=0; //was tif.tif_rawdata;
                tif.tif_rawcc=td.td_stripbytecount[tile];
            }

            return tif.tif_predecode(tif, (ushort)(tile/td.td_stripsperimage));
        }
Esempio n. 5
0
        // Set state to appear as if a
        // strip has just been read in.
        static bool TIFFStartStrip(TIFF tif, uint strip)
        {
            TIFFDirectory td=tif.tif_dir;

            if((tif.tif_flags&TIF_FLAGS.TIFF_CODERSETUP)==0)
            {
                if(!tif.tif_setupdecode(tif)) return false;
                tif.tif_flags|=TIF_FLAGS.TIFF_CODERSETUP;
            }
            tif.tif_curstrip=strip;
            tif.tif_row=(strip%td.td_stripsperimage)*td.td_rowsperstrip;
            if((tif.tif_flags&TIF_FLAGS.TIFF_NOREADRAW)==TIF_FLAGS.TIFF_NOREADRAW)
            {
                tif.tif_rawdata=null; // ?????
                tif.tif_rawcp=0;
                tif.tif_rawcc=0;
            }
            else
            {
                tif.tif_rawcp=0; //was tif.tif_rawdata;
                tif.tif_rawcc=td.td_stripbytecount[strip];
            }
            return tif.tif_predecode(tif, (ushort)(strip/td.td_stripsperimage));
        }
Esempio n. 6
0
		// Setup state for decoding a strip.
		static bool LZWPreDecode(TIFF tif, ushort sampleNumber)
		{
			LZWCodecState sp=tif.tif_data as LZWCodecState;

#if DEBUG
			if(sp==null) throw new Exception("sp==null");
#endif
			if(sp.dec_codetab==null)
			{
				tif.tif_setupdecode(tif);
			}

			// Check for old bit-reversed codes.
			if(tif.tif_rawdata[0]==0&&(tif.tif_rawdata[1]&0x1)!=0)
			{
#if LZW_COMPAT
				if(sp.dec_decode==null)
				{
					TIFFWarningExt(tif.tif_clientdata, tif.tif_name, "Old-style LZW codes, convert file");

					// Override default decoding methods with
					// ones that deal with the old coding.
					// Otherwise the predictor versions set
					// above will call the compatibility routines
					// through the dec_decode method.
					tif.tif_decoderow=LZWDecodeCompat;
					tif.tif_decodestrip=LZWDecodeCompat;
					tif.tif_decodetile=LZWDecodeCompat;

					// If doing horizontal differencing, must
					// re-setup the predictor logic since we
					// switched the basic decoder methods...
					tif.tif_setupdecode(tif);
					sp.dec_decode=LZWDecodeCompat;
				}

				sp.maxcode=(ushort)MAXCODE(BITS_MIN);
#else // !LZW_COMPAT
				if(sp.dec_decode==null)
				{
					TIFFErrorExt(tif.tif_clientdata, tif.tif_name, "Old-style LZW codes not supported");
					sp.dec_decode=LZWDecode;
				}
				return false;
#endif // !LZW_COMPAT
			}
			else
			{
				sp.maxcode=(ushort)(MAXCODE(BITS_MIN)-1);
				sp.dec_decode=LZWDecode;
			}
			sp.nbits=BITS_MIN;
			sp.nextbits=0;
			sp.nextdata=0;

			sp.dec_restart=0;
			sp.dec_nbitsmask=MAXCODE(BITS_MIN);
#if LZW_CHECKEOS
			sp.dec_bitsleft=(int)(tif.tif_rawcc<<3);
#endif
			sp.dec_free_entp=CODE_FIRST;

			// Zero entries that are not yet filled in. We do
			// this to guard against bogus input data that causes
			// us to index into undefined entries. If you can
			// come up with a way to safely bounds-check input codes
			// while decoding then you can remove this operation.
			for(int i=sp.dec_free_entp; i<CSIZE; i++)
			{
				sp.dec_codetab[i].firstchar=0;
				sp.dec_codetab[i].length=0;
				sp.dec_codetab[i].value=0;
				sp.dec_codetab[i].next=-1;
			}

			sp.dec_oldcodep=-1;
			sp.dec_maxcodep=sp.dec_nbitsmask-1;
			return true;
		}
Esempio n. 7
0
        // Setup state for decoding a strip.
        static bool ZIPPreDecode(TIFF tif, ushort sampleNumber)
        {
            ZIPState sp=tif.tif_data as ZIPState;

            #if DEBUG
            if(sp==null) throw new Exception("sp==null");
            #endif

            if((sp.state&ZSTATE.INIT_DECODE)!=ZSTATE.INIT_DECODE)
                tif.tif_setupdecode(tif);

            sp.stream.in_buf=tif.tif_rawdata;
            sp.stream.next_in=0;
            sp.stream.avail_in=tif.tif_rawcc;
            return zlib.inflateReset(sp.stream)==zlib.Z_OK;
        }