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

WriteBufferSetup() public method

Sets up the data buffer used to write raw (encoded) data to 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 size is -1 then the buffer size is selected to hold a complete tile or strip, or at least 8 kilobytes, whichever is greater. If the buffer is null, then a buffer of appropriate size is allocated by the library.

public WriteBufferSetup ( byte buffer, int size ) : void
buffer byte The data buffer.
size int The buffer size.
return void
        public void WriteBufferSetup(byte[] buffer, int size)
        {
            if (m_rawdata != null)
            {
                if ((m_flags & TiffFlags.MYBUFFER) == TiffFlags.MYBUFFER)
                    m_flags &= ~TiffFlags.MYBUFFER;

                m_rawdata = null;
            }

            if (size == -1)
            {
                size = (IsTiled() ? m_tilesize : StripSize());

                // Make raw data buffer at least 8K
                if (size < 8 * 1024)
                    size = 8 * 1024;

                // force allocation
                buffer = null;
            }

            if (buffer == null)
            {
                buffer = new byte[size];
                m_flags |= TiffFlags.MYBUFFER;
            }
            else
            {
                m_flags &= ~TiffFlags.MYBUFFER;
            }

            m_rawdata = buffer;
            m_rawdatasize = size;
            m_rawcc = 0;
            m_rawcp = 0;
            m_flags |= TiffFlags.BUFFERSETUP;
        }
Tiff