TIFFSWAB(3tiff)

πŸ’… TIFFSWAB β€” byte- and bit-swapping routines

okay bestie, welcome to TIFFswab(3tiff) from LibTIFF β€” the little family of functions that flips your bytes around so your endianness situation stops being a whole mess. it's giving endianness rescue mission and honestly? obsessed. πŸ¦‹


✨ SYNOPSIS ✨

#include <tiffio.h>

const unsigned char *TIFFGetBitRevTable(int reversed)

void TIFFReverseBits(u_char *data, unsigned long nbytes)

void TIFFSwabShort(uint16_t *data)

void TIFFSwabLong(uint32_t *data)

void TIFFSwabLong8(uint64_t *lp)

void TIFFSwabFloat(float *fp)

void TIFFSwabDouble(double *dp)

void TIFFSwabArrayOfShort(uint16_t *wp, tmsize_t n)

void TIFFSwabArrayOfTriples(uint8_t *tp, tmsize_t n)

void TIFFSwabArrayOfLong(uint32_t *lp, tmsize_t n)

void TIFFSwabArrayOfLong8(uint64_t *lp, tmsize_t n)

void TIFFSwabArrayOfFloat(float *fp, tmsize_t n)

void TIFFSwabArrayOfDouble(double *dp, tmsize_t n)

🌸 DESCRIPTION 🌸

so here's the tea β˜•: these routines are the ones the library itself uses to swap 16-, 32- and 64-bit data around, plus reverse the order of bits inside bytes. lowkey iconic of them.

  • TIFFSwabShort() and TIFFSwabLong() and TIFFSwabFloat() β€” swap the bytes in a single 16- and 32-bit item, respectively.
  • TIFFSwabLong8() and TIFFSwabDouble() β€” swap the bytes in a single 64-bit item.
  • TIFFSwabArrayOfTriples() β€” swaps the first and the third byte of each triple (three bytes) inside the byte array. the second byte of each triple stays untouched, minding its own business. πŸ™ˆ
  • TIFFSwabArrayOfShort() and TIFFSwabArrayOfLong(), TIFFSwabArrayOfFloat() β€” swap the bytes in an array of 16- and 32-bit items, respectively.
  • TIFFSwabArrayOfLong8() and TIFFSwabArrayOfDouble() β€” swap the bytes in an array of 64-bit items.

and then there's TIFFReverseBits() πŸ’« β€” it replaces each byte in data with the equivalent bit-reversed value. this operation is performed with a lookup table, which is returned using the TIFFGetBitRevTable() function.

the reversed parameter specifies which table should be returned, so listen up:

  1. Supply 1 if you want the bit reversal table.
  2. Supply 0 to get the table that does not reverse bit values. it's a lookup table that can be used as an "identity function"; i.e. TIFFNoBitRevTable[n] == n.
fr fr, pick your table wisely β€” 1 flips, 0 does absolutely nothing and that's the whole point of it. πŸ‘‘

πŸ’€ DIAGNOSTICS πŸ’€

None.

like… none at all. no drama, no error codes, nothing. she's silent. 🀫


πŸ‘€ SEE ALSO πŸ‘€

  • libtiff (3tiff)

🫢 AUTHOR 🫢

LibTIFF contributors


1988-2025, LibTIFF contributors


and that's the whole page, bestie β€” slay πŸ’– this was LibTIFF version 4.7, dated Jun 27, 2026, and yes she ate, periodt. βœ¨πŸ§šπŸ’œ