TIFFREADRGBASTRIP(3tiff)

๐Ÿ’– TIFFReadRGBAStrip โ€” bestie edition ๐Ÿ’–

okay so you're here because you want to read ONE strip of a TIFF and get RGBA out of it, and honestly? valid. this is TIFFReadRGBAStrip from LibTIFF, living in the 3tiff manual section, and I'm gonna walk you through it like we're texting at 2am. ๐Ÿฆ‹


โœจ NAME โœจ

TIFFReadRGBAStrip โ€” read and decode an image strip into a fixed-format raster. that's the whole vibe. ๐ŸŽ€


โœจ SYNOPSIS โœจ

#include <tiffio.h>

int TIFFReadRGBAStrip(TIFF *tif, uint32_t row, uint32_t *raster)

int TIFFReadRGBAStripExt(TIFF *tif, uint32_t row, uint32_t *raster, int stop_on_error)

โœจ DESCRIPTION โœจ

so TIFFReadRGBAStrip() reads a single strip of a strip-based image into memory and drops the result into the RGBA raster you supply. it's giving "I don't need the whole image, just this one strip, thanks." ๐Ÿ’…

the raster is assumed to be an array of ImageWidth ร— RowsPerStrip 32-bit entries, where ImageWidth is the width of the image (TIFFTAG_IMAGEWIDTH) and RowsPerStrip is the maximum lines in a strip (TIFFTAG_ROWSPERSTRIP). do the math, allocate accordingly, no cap. ๐Ÿงฎ

TIFFReadRGBAStripExt() is the same girl but she brings a friend: the stop_on_error parameter. its behaviour is described over at TIFFReadRGBAImage. go look, iykyk. ๐Ÿ‘€

the row value should be the row of the first row in the strip โ€” that's strip ร— RowsPerStrip, zero based. zero based!! do not forget!! ๐Ÿ˜ญ

โš ๏ธ okay important: the raster is assumed to be organized such that the pixel at location (x, y) is raster [ y ร— width + x ], with the raster origin in the lower-left hand corner of the strip. that is bottom to top organization. so it's not top-down like your brain wants it to be. ๐Ÿ™ˆ when reading a partial last strip in the file, the last line of the image will begin at the beginning of the buffer.

raster pixels are 8-bit packed red, green, blue, alpha samples. the macros TIFFGetR, TIFFGetG, TIFFGetB, and TIFFGetA should be used to access individual samples โ€” don't go poking bytes yourself bestie. ๐Ÿ’€ images without Associated Alpha matting information have a constant Alpha of 1.0 (255).

for the deets on how various image types get converted to RGBA values, see the TIFFRGBAImage page. she explains everything. ๐Ÿ’–


โœจ NOTES โœจ

ngl, TIFFReadRGBAStrip() is just a wrapper around the more general TIFFRGBAImage facilities. its main advantage over the similar TIFFReadRGBAImage() function is that for large images a single buffer capable of holding the whole image doesn't need to be allocated โ€” only enough for one strip. memory stays cute and small. ๐ŸŒธ

the TIFFReadRGBATile() function does a similar operation for tiled images, in case your image is that girl instead. โœจ

for general notes see TIFFRGBImage notes. ๐Ÿ“


โœจ RETURN VALUES โœจ

1 is returned if the image was successfully read and converted. otherwise, 0 is returned if an error was encountered.

so: 1 = slay, 0 = not slay. periodt. ๐Ÿ‘‘


โœจ DIAGNOSTICS โœจ

all error messages are directed to the TIFFErrorExtR() routine. here's the full roster of complaints she might throw at you: ๐Ÿ’€

  • "Sorry, can not handle %d-bit pictures" โ€” the image had BitsPerSample other than 1, 2, 4, 8, or 16.
  • "Sorry, can not handle %d-channel images" โ€” the image had SamplesPerPixel other than 1, 3, or 4.
  • Missing needed "PhotometricInterpretation" tag โ€” the image did not have a tag that describes how to display the data.
  • No "PhotometricInterpretation" tag, assuming RGB โ€” the image was missing a tag that describes how to display it, but because it has 3 or 4 samples/pixel, it is assumed to be RGB.
  • No "PhotometricInterpretation" tag, assuming min-is-black โ€” the image was missing a tag that describes how to display it, but because it has 1 sample/pixel, it is assumed to be a grayscale or bilevel image.
  • "No space for photometric conversion table" โ€” there was insufficient memory for a table used to convert image samples to 8-bit RGB.
  • Missing required "Colormap" tag โ€” a Palette image did not have a required Colormap tag.
  • "No space for tile buffer" โ€” there was insufficient memory to allocate an i/o buffer.
  • "No space for strip buffer" โ€” there was insufficient memory to allocate an i/o buffer.
  • "Can not handle format" โ€” the image has a format (combination of BitsPerSample, SamplesPerPixel, and PhotometricInterpretation) that TIFFReadRGBAImage() can not handle.
  • "No space for B&W mapping table" โ€” there was insufficient memory to allocate a table used to map grayscale data to RGB.
  • "No space for Palette mapping table" โ€” there was insufficient memory to allocate a table used to map data to 8-bit RGB.

โœจ SEE ALSO โœจ

  • TIFFOpen (3tiff)
  • TIFFRGBAImage (3tiff)
  • TIFFReadRGBAImage (3tiff)
  • TIFFReadRGBATile (3tiff)
  • libtiff (3tiff)

โœจ AUTHOR โœจ

LibTIFF contributors ๐Ÿซถ


1988-2025, LibTIFF contributors


and that's the whole page bestie!! ๐Ÿ’œ this was LibTIFF version 4.7, dated Jun 27, 2026 โ€” go read a strip, stay bottom-to-top, and don't forget your TIFFGetR/TIFFGetG/TIFFGetB/TIFFGetA macros. mwah. ๐Ÿ’…โœจ๐ŸŽ€