Debian Codegraph @

texk/xdvipsk/thirdparty/libtiff/doc/functions/TIFFWriteScanline.rst

raw
1 TIFFWriteScanline
2 =================
3
4 Synopsis
5 --------
6
7 .. highlight:: c
8
9 ::
10
11 #include <tiffio.h>
12
13 .. c:function:: int TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32_t row, tsample_t sample)
14
15 Description
16 -----------
17
18 Write data to a file at the specified row. The *sample* parameter is
19 used only if data are organized in separate planes
20 (``PlanarConfiguration`` = 2).
21 The data are assumed to be uncompressed and in the native bit- and
22 byte-order of the host machine. The data written to the file is
23 compressed according to the compression scheme of the current
24 TIFF directory (see further below). If the current scanline is past the
25 end of the current subfile, the ``ImageLength`` field is automatically
26 increased to include the scanline (except for ``PlanarConfiguration`` = 2,
27 where the ``ImageLength`` cannot be changed once the first data are
28 written). If the ``ImageLength`` is increased, the ``StripOffsets``
29 and ``StripByteCounts`` fields are similarly enlarged to reflect data
30 written past the previous end of image.
31
32 Notes
33 -----
34
35 The library writes encoded data using the native machine byte order.
36 Correctly implemented TIFF readers are expected to do any necessary
37 byte-swapping to correctly process image data with ``BitsPerSample``
38 greater than 8. The library attempts to hide bit-ordering differences
39 between the image and the native machine by converting data from the
40 native machine order.
41
42 In C++ the *sample* parameter defaults to 0.
43
44 Once data are written to a file for the current directory, the values of
45 certain tags may not be altered; see :c:func:`TIFFSetField` for more
46 information.
47
48 It is not possible to write scanlines to a file that uses a tiled
49 organization. The routine :c:func:`TIFFIsTiled` can be used to
50 determine if the file is organized as tiles or strips.
51
52 Return values
53 -------------
54
55 :c:func:`TIFFWriteScanline` returns -1 if it immediately detects an
56 error and 1 for a successful write.
57
58 Diagnostics
59 -----------
60
61 All error messages are directed to the :c:func:`TIFFErrorExtR` routine.
62
63 ``%s: File not open for writing``:
64
65 The file was opened for reading, not writing.
66
67 ``"Can not write scanlines to a tiled image"``:
68
69 An attempt was made to write a scanline to a tiled image. The image
70 is assumed to be organized in tiles because the ``TileWidth`` and
71 ``TileLength`` tags have been set with :c:func:`TIFFSetField`.
72
73 ``"Compression algorithm does not support random access"``:
74
75 Data was written in a non-sequential order to a file that uses a
76 compression algorithm and that has ``RowsPerStrip`` greater than one.
77 That is, data in the image is to be stored in a compressed form, and
78 with multiple rows packed into a strip. In this case, the library
79 does not support random access to the data. The data should either be
80 written as entire strips, sequentially by rows, or the value of
81 ``RowsPerStrip`` should be set to one.
82
83 ``%s: Must set "ImageWidth" before writing data``:
84
85 The image's width has not be set before the first write.
86 See :c:func:`TIFFSetField` for information on how to do this.
87
88 ``%s: Must set "PlanarConfiguration" before writing data``:
89
90 The organization of data has not be defined before the first write.
91 See :c:func:`TIFFSetField` for information on how to do this.
92
93 ``Can not change "ImageLength" when using separate planes``:
94
95 Separate image planes are being used (``PlanarConfiguration`` = 2),
96 but the number of rows has not been specified before the first write.
97 The library supports the dynamic growth of an image only when data
98 are organized in a contiguous manner (``PlanarConfiguration`` = 1).
99
100 ``"%d: Sample out of range, max %d"``:
101
102 The *sample* parameter was greater than the value of the
103 ``SamplesPerPixel`` tag.
104
105 ``%s: No space for strip arrays``:
106
107 There was not enough space for the arrays that hold strip offsets and
108 byte counts.
109
110 Bugs
111 ----
112
113 Writing subsampled YCbCR data does not work correctly because, for
114 ``PlanarConfiguration`` = 2 the size of a scanline is not calculated on
115 a per-sample basis, and for ``PlanarConfiguration`` = 1 the library
116 does not pack the block-interleaved samples.
117
118 See also
119 --------
120
121 :doc:`TIFFOpen` (3tiff),
122 :doc:`TIFFWriteEncodedStrip` (3tiff),
123 :doc:`TIFFWriteRawStrip` (3tiff),
124 :doc:`libtiff` (3tiff)