Table of Contents
TIFF: reading the tags of a TIFF structured buffer
Structures
| Name | |
|---|---|
| struct | N_TIFF_ENTRY One directory entry. |
| struct | N_TIFF The first directory of a TIFF structured buffer. |
Functions
| Name | |
|---|---|
| N_TIFF * | n_tiff_parse_ifd(const unsigned char * data, size_t len, size_t ifd) Parse a directory at a given offset of a TIFF structured buffer: a sub-directory such as EXIF's, whose offset another directory's pointer tag holds. |
| N_TIFF * | n_tiff_parse(const unsigned char * data, size_t len) Parse the first directory of a TIFF structured buffer. |
| size_t | n_tiff_get_doubles(const N_TIFF * tiff, uint16_t tag, double * out, size_t max) Read a numeric tag as doubles. |
| int | n_tiff_get_ascii(const N_TIFF * tiff, uint16_t tag, char * out, size_t out_len) Read an ASCII tag. |
| void | n_tiff_free(N_TIFF ** tiff) Release a parse, and set the pointer to NULL. |
| const N_TIFF_ENTRY * | n_tiff_find(const N_TIFF * tiff, uint16_t tag) Find an entry by tag. |
| size_t | n_tiff_count(const N_TIFF * tiff, uint16_t tag) How many values a tag has. |
Defines
| Name | |
|---|---|
| N_TIFF_MAGIC_DCP The magic of an Adobe DCP camera profile, "RC" read little endian. |
|
| N_TIFF_MAGIC The magic of a plain TIFF file. |
Functions Documentation
function n_tiff_parse_ifd
N_TIFF * n_tiff_parse_ifd(
const unsigned char * data,
size_t len,
size_t ifd
)
Parse a directory at a given offset of a TIFF structured buffer: a sub-directory such as EXIF's, whose offset another directory's pointer tag holds.
Parameters:
- data the buffer from its TIFF header, borrowed: it must outlive the result
- len its length in bytes
- ifd the directory's offset from the header, as a pointer tag gives it
Return: a new N_TIFF to release with n_tiff_free(), or NULL when the header or the directory is not readable
The byte order is the header's, as the offsets inside are relative to the header; the same checks as n_tiff_parse() apply.
function n_tiff_parse
N_TIFF * n_tiff_parse(
const unsigned char * data,
size_t len
)
Parse the first directory of a TIFF structured buffer.
Parameters:
- data the buffer, borrowed: it must outlive the result
- len its length in bytes
Return: a new N_TIFF to release with n_tiff_free(), or NULL when the header or the directory is not readable
Entries of an unknown type or whose values lie outside the buffer are skipped.
function n_tiff_get_doubles
size_t n_tiff_get_doubles(
const N_TIFF * tiff,
uint16_t tag,
double * out,
size_t max
)
Read a numeric tag as doubles.
Parameters:
- tiff the parse
- tag the tag number
- out receives up to max values
- max room in out
Return: how many values were written, 0 when the tag is missing or not numeric
BYTE, SHORT, LONG, RATIONAL and their signed forms, FLOAT and DOUBLE are converted; a rational with a zero denominator reads as 0.
function n_tiff_get_ascii
int n_tiff_get_ascii(
const N_TIFF * tiff,
uint16_t tag,
char * out,
size_t out_len
)
Read an ASCII tag.
Parameters:
- tiff the parse
- tag the tag number
- out receives the string
- out_len size of out, at least 1
Return: 0 when read, -1 when the tag is missing or not ASCII (out is then empty)
The string is cut to the first NUL and to out_len - 1 bytes, and always terminated.
function n_tiff_free
void n_tiff_free(
N_TIFF ** tiff
)
Release a parse, and set the pointer to NULL.
Parameters:
- tiff address of the N_TIFF pointer, may point to NULL
The buffer is not touched.
function n_tiff_find
const N_TIFF_ENTRY * n_tiff_find(
const N_TIFF * tiff,
uint16_t tag
)
Find an entry by tag.
Parameters:
- tiff the parse
- tag the tag number
Return: the first entry with that tag, or NULL
function n_tiff_count
size_t n_tiff_count(
const N_TIFF * tiff,
uint16_t tag
)
How many values a tag has.
Parameters:
- tiff the parse
- tag the tag number
Return: its count, 0 when the tag is not there
Macros Documentation
define N_TIFF_MAGIC_DCP
#define N_TIFF_MAGIC_DCP 0x4352
The magic of an Adobe DCP camera profile, "RC" read little endian.
define N_TIFF_MAGIC
#define N_TIFF_MAGIC 42
The magic of a plain TIFF file.
Modules
- AABB3D
- ACCEPT_POOL
- ALLEGRO4
- ALLEGRO5
- ANIM_LIB
- ASTAR
- ATLAS_LIB
- AVRO
- CLOCK_SYNC
- COMMONS
- CONFIGFILE
- CYPHER_BASE64
- CYPHER_VIGENERE
- DEAD_RECKONING
- ENUMS
- EXCEPTIONS
- GAME_ENV
- GIT
- GUI
- HASH_TABLE
- ISOMETRIC_ENGINE
- LIST
- LOG
- LOGNODUP
- LZ4
- NETWORKING
- NETWORK_MSG
- N_COOKIES
- N_DIFF
- N_DIGEST
- N_DISK_CACHE
- N_DNS
- N_ECC
- N_ENTROPY
- N_FILES
- N_FLUIDS
- N_GUI_COLOR
- N_GUI_COLORWHEEL
- N_GUI_CURVE
- N_GUI_GRID
- N_GUI_POPUP
- N_HEX
- N_HTTP3
- N_HTTP_COOKIE
- N_HTTP_FORM
- N_HTTP_MIME
- N_HTTP_REQ
- N_HTTP_RESP
- N_HTTP_ROUTER
- N_HTTP_SERVER
- N_ICC
- N_JSON
- N_KAFKA
- N_LINALG
- N_MODULE
- N_OPENSSL_COMPAT
- N_PRETTY
- N_PTH
- N_QUERY
- N_RANDOM
- N_SHA256
- N_STR
- N_TIFF
- N_TIME
- N_USER
- N_X509
- N_ZIP
- PARTICLES
- PCRE
- PHYSICS
- SIGNALS
- STACK
- THREADS
- TRAJECTORY
- TREE
- ZLIB