TIFFREADSCANLINE(3tiff)

πŸ’– TIFFREADSCANLINE πŸ’–

okay bestie, welcome to the 3tiff manual page for TIFFReadScanline β€” yes that's the whole name, and yes she's iconic. This is the one that reads and decodes a scanline of data from an open TIFF file. Let's get into it πŸ¦‹


✨ SYNOPSIS ✨

#include <tiffio.h>

int TIFFReadScanline(TIFF *tif, void *buf, uint32_t row, uint16_t sample)

like. that's the whole vibe. four args, one int coming back at you πŸ’…


🌸 DESCRIPTION 🌸

So what she does is read the data for the specified row into the (user supplied) data buffer buf β€” you're bringing the buffer, she's bringing the bytes, it's a whole collab 🀝

The data come back decompressed and in the native byte- and bit-ordering, but are otherwise packed (more on that below, don't worry). The buffer must be large enough to hold an entire scanline of data β€” no half measures, bestie, she will not be doing math for you.

Applications should call TIFFScanlineSize() to find out the size (in bytes) of a scanline buffer. Literally just ask her. She knows. πŸ‘‘

The row parameter is always used by TIFFReadScanline(); the sample parameter is used only if data are organized in separate planes (PlanarConfiguration = 2). So if your planes are chillin' together, sample is just there for moral support πŸ™ˆ


πŸŽ€ NOTES πŸŽ€

The library attempts to hide bit- and byte-ordering differences between the image and the native machine by converting data to the native machine order. Very thoughtful of her, honestly. 🫢

  • Bit reversal is done if the FillOrder tag is opposite to the native machine bit order.
  • 16- and 32-bit samples are automatically byte-swapped if the file was written with a byte order opposite to the native machine byte order.

In C++ the sample parameter defaults to 0. cute, low-effort, we love a default πŸ’œ


πŸ”₯ RETURN VALUES πŸ”₯

TIFFReadScanline() returns -1 if it detects an error; otherwise 1 is returned.

so it's giving binary. either we ate or we didn't. no in-between πŸ’€


πŸ‘‘ DIAGNOSTICS πŸ‘‘

All error messages are directed to the TIFFErrorExtR() routine.

"Compression algorithm does not support random access"

Data was requested in a non-sequential order from a file that uses a compression algorithm and that has RowsPerStrip greater than one. That is, data in the image is stored in a compressed form, and with multiple rows packed into a strip. In this case, the library does not support random access to the data.

The data should either be accessed sequentially, or the file should be converted so that each strip is made up of one row of data. no skipping around, bestie, this is a line, not a playlist 🎧

πŸ’€ BUGS πŸ’€

Reading subsampled YCbCR data does not work correctly, and here's why (not me exposing her):

  • for PlanarConfiguration = 2, the size of a scanline is not calculated on a per-sample basis
  • for PlanarConfiguration = 1, the library does not unpack the block-interleaved samples
use the strip- and tile-based interfaces to read these formats. fr fr, that's the move 🧚

🌈 SEE ALSO 🌈

  • TIFFOpen (3tiff)
  • TIFFReadEncodedStrip (3tiff)
  • TIFFReadRawStrip (3tiff)
  • libtiff (3tiff)

go read the whole friend group, they're all slay πŸ’–


πŸ’… AUTHOR πŸ’…

LibTIFF contributors


1988-2025, LibTIFF contributors


and that's the page!! this was LibTIFF version 4.7, dated Jun 27, 2026 β€” thanks for coming to my TED talk, now go read a scanline sequentially like a good little main character β­πŸ’œ πŸŽ€