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

ReadScanline() public method

Reads and decodes a scanline of data from an open TIFF file/stream.

ReadScanline reads the data for the specified row into the user supplied data buffer buffer. The data are returned decompressed and, in the native byte- and bit-ordering, but are otherwise packed (see further below). The buffer must be large enough to hold an entire scanline of data. Applications should call the ScanlineSize to find out the size (in bytes) of a scanline buffer. Applications should use ReadScanline(byte[], int, short) or ReadScanline(byte[], int, int, short) and specify correct sample plane if image data are organized in separate planes (TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE).

The library attempts to hide bit- and byte-ordering differences between the image and the native machine by converting data to the native machine order. Bit reversal is done if the value of TiffTag.FILLORDER tag is opposite to the native machine bit order. 16- and 32-bit samples are automatically byte-swapped if the file was written with a byte order opposite to the native machine byte order.

public ReadScanline ( byte buffer, int row ) : bool
buffer byte The buffer to place read and decoded image data to.
row int The zero-based index of scanline (row) to read.
return bool
        public bool ReadScanline(byte[] buffer, int row)
        {
            return ReadScanline(buffer, 0, row, 0);
        }

Same methods

Tiff::ReadScanline ( byte buffer, int offset, int row, short plane ) : bool
Tiff::ReadScanline ( byte buffer, int row, short plane ) : bool

Usage Example

コード例 #1
0
ファイル: Copier.cs プロジェクト: XiBeichuan/hydronumerics
        /*
         * Separate -> contig by row.
         */
        bool cpSeparate2ContigByRow(Tiff inImage, Tiff outImage, int imagelength, int imagewidth, short spp)
        {
            byte[] inbuf = new byte[inImage.ScanlineSize()];
            byte[] outbuf = new byte[outImage.ScanlineSize()];

            for (int row = 0; row < imagelength; row++)
            {
                /* merge channels */
                for (short s = 0; s < spp; s++)
                {
                    if (!inImage.ReadScanline(inbuf, row, s) && !m_ignore)
                    {
                        Tiff.Error(inImage.FileName(), "Error, can't read scanline {0}", row);
                        return false;
                    }

                    int inp = 0;
                    int outp = s;

                    for (int n = imagewidth; n-- > 0; )
                    {
                        outbuf[outp] = inbuf[inp];
                        inp++;
                        outp += spp;
                    }
                }

                if (!outImage.WriteScanline(outbuf, row, 0))
                {
                    Tiff.Error(outImage.FileName(), "Error, can't write scanline {0}", row);
                    return false;
                }
            }

            return true;
        }
All Usage Examples Of BitMiracle.LibTiff.Classic.Tiff::ReadScanline
Tiff