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

ReadBufferSetup() public method

Sets up the data buffer used to read raw (encoded) data from a file.

This method is provided for client-control of the I/O buffers used by the library. Applications need never use this method; it's provided only for "intelligent clients" that wish to optimize memory usage and/or eliminate potential copy operations that can occur when working with images that have data stored without compression.

If the buffer is null, then a buffer of appropriate size is allocated by the library. Otherwise, the caller must guarantee that the buffer is large enough to hold any individual strip of raw data.

public ReadBufferSetup ( byte buffer, int size ) : void
buffer byte The data buffer.
size int The buffer size.
return void
        public void ReadBufferSetup(byte[] buffer, int size)
        {
            Debug.Assert((m_flags & TiffFlags.NOREADRAW) != TiffFlags.NOREADRAW);
            m_rawdata = null;

            if (buffer != null)
            {
                m_rawdatasize = size;
                m_rawdata = buffer;
                m_flags &= ~TiffFlags.MYBUFFER;
            }
            else
            {
                m_rawdatasize = roundUp(size, 1024);
                if (m_rawdatasize > 0)
                {
                    m_rawdata = new byte[m_rawdatasize];
                }
                else
                {
                    Tiff.ErrorExt(this, m_clientdata,
                        "ReadBufferSetup", "{0}: No space for data buffer at scanline {1}", m_name, m_row);
                    m_rawdatasize = 0;
                }

                m_flags |= TiffFlags.MYBUFFER;
            }
        }
Tiff