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

WriteScanline() public method

Encodes and writes a scanline of data to an open TIFF file/stream.

WriteScanline encodes and writes to a file at the specified row. Applications should use WriteScanline(byte[], int, short) or WriteScanline(byte[], int, int, short) and specify correct sample plane parameter if image data in a file/stream is organized in separate planes (i.e TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE).

The data are assumed to be uncompressed and in the native bit- and byte-order of the host machine. The data written to the file is compressed according to the compression scheme of the current TIFF directory (see further below). If the current scanline is past the end of the current subfile, the value of TiffTag.IMAGELENGTH tag is automatically increased to include the scanline (except for TiffTag.PLANARCONFIG = PlanarConfig.SEPARATE, where the TiffTag.IMAGELENGTH tag cannot be changed once the first data are written). If the TiffTag.IMAGELENGTH is increased, the values of TiffTag.STRIPOFFSETS and TiffTag.STRIPBYTECOUNTS tags are similarly enlarged to reflect data written past the previous end of image.

The library writes encoded data using the native machine byte order. Correctly implemented TIFF readers are expected to do any necessary byte-swapping to correctly process image data with value of TiffTag.BITSPERSAMPLE tag greater than 8. The library attempts to hide bit-ordering differences between the image and the native machine by converting data from the native machine order.

Once data are written to a file/stream for the current directory, the values of certain tags may not be altered; see "Well-known tags and their value(s) data types" for more information.

It is not possible to write scanlines to a file/stream that uses a tiled organization. The IsTiled can be used to determine if the file/stream is organized as tiles or strips.

public WriteScanline ( byte buffer, int row ) : bool
buffer byte The buffer with image data to be encoded and written.
row int The zero-based index of scanline (row) to place encoded data at.
return bool
        public bool WriteScanline(byte[] buffer, int row)
        {
            return WriteScanline(buffer, 0, row, 0);
        }

Same methods

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

Usage Example

示例#1
0
        /*
         * 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::WriteScanline
Tiff