BitMiracle.LibTiff.Classic.Internal.JpegCodec.JPEGEncode C# (CSharp) Метод

JPEGEncode() приватный Метод

Encode a chunk of pixels. "Standard" case: incoming data is not downsampled.
private JPEGEncode ( byte buffer, int offset, int count, short plane ) : bool
buffer byte
offset int
count int
plane short
Результат bool
        private bool JPEGEncode(byte[] buffer, int offset, int count, short plane)
        {
            // data is expected to be supplied in multiples of a scanline
            int nrows = count / m_bytesperline;
            if ((count % m_bytesperline) != 0)
                Tiff.WarningExt(m_tif, m_tif.m_clientdata, m_tif.m_name, "fractional scanline discarded");

            // The last strip will be limited to image size
            if (!m_tif.IsTiled() && m_tif.m_row + nrows > m_tif.m_dir.td_imagelength)
                nrows = m_tif.m_dir.td_imagelength - m_tif.m_row;

            byte[][] bufptr = new byte[1][];
            bufptr[0] = new byte[m_bytesperline];
            while (nrows-- > 0)
            {
                Buffer.BlockCopy(buffer, offset, bufptr[0], 0, m_bytesperline);
                if (TIFFjpeg_write_scanlines(bufptr, 1) != 1)
                    return false;

                if (nrows > 0)
                    m_tif.m_row++;

                offset += m_bytesperline;
            }

            return true;
        }