Esempio n. 1
0
        // Read a tile of data and decompress the specified
        // amount into the user-supplied buffer.
        public static int TIFFReadEncodedTile(TIFF tif, uint tile, byte[] buf, int size)
        {
            TIFFDirectory td       = tif.tif_dir;
            int           tilesize = tif.tif_tilesize;

            if (!TIFFCheckRead(tif, true))
            {
                return(-1);
            }

            if (tile >= td.td_nstrips)
            {
                TIFFErrorExt(tif.tif_clientdata, tif.tif_name, "{0}: Tile out of range, max {1}", tile, td.td_nstrips);
                return(-1);
            }

            if (size == -1)
            {
                size = tilesize;
            }
            else if (size > tilesize)
            {
                size = tilesize;
            }

            if (TIFFFillTile(tif, tile) && tif.tif_decodetile(tif, buf, size, (ushort)(tile / td.td_stripsperimage)))
            {
                tif.tif_postdecode(tif, buf, 0, size);
                return(size);
            }

            return(-1);
        }
Esempio n. 2
0
        // Read a tile of data and decompress the specified
        // amount into the user-supplied buffer.
        public static int TIFFReadEncodedTile(TIFF tif, uint tile, byte[] buf, int size)
        {
            TIFFDirectory td=tif.tif_dir;
            int tilesize=tif.tif_tilesize;

            if(!TIFFCheckRead(tif, true)) return -1;

            if(tile>=td.td_nstrips)
            {
                TIFFErrorExt(tif.tif_clientdata, tif.tif_name, "{0}: Tile out of range, max {1}", tile, td.td_nstrips);
                return -1;
            }

            if(size==-1) size=tilesize;
            else if(size>tilesize) size=tilesize;

            if(TIFFFillTile(tif, tile)&&tif.tif_decodetile(tif, buf, size, (ushort)(tile/td.td_stripsperimage)))
            {
                tif.tif_postdecode(tif, buf, 0, size);
                return size;
            }

            return -1;
        }