Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_tiff.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
46
47#ifndef N_TIFF_HEADER_GUARD
48#define N_TIFF_HEADER_GUARD
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
58
59#include <stddef.h>
60#include <stdint.h>
61
63#define N_TIFF_MAGIC 42
65#define N_TIFF_MAGIC_DCP 0x4352
66
68typedef struct N_TIFF_ENTRY {
70 uint16_t tag;
72 uint16_t type;
74 uint32_t count;
76 size_t offset;
78
80typedef struct N_TIFF {
82 const unsigned char* data;
84 size_t len;
88 uint16_t magic;
92 size_t count;
93} N_TIFF;
94
99N_TIFF* n_tiff_parse(const unsigned char* data, size_t len);
100
106N_TIFF* n_tiff_parse_ifd(const unsigned char* data, size_t len, size_t ifd);
107
110void n_tiff_free(N_TIFF** tiff);
111
116const N_TIFF_ENTRY* n_tiff_find(const N_TIFF* tiff, uint16_t tag);
117
122size_t n_tiff_count(const N_TIFF* tiff, uint16_t tag);
123
130size_t n_tiff_get_doubles(const N_TIFF* tiff, uint16_t tag, double* out, size_t max);
131
138int n_tiff_get_ascii(const N_TIFF* tiff, uint16_t tag, char* out, size_t out_len);
139
143
144#ifdef __cplusplus
145}
146#endif
147
148#endif
size_t offset
where the values start in the buffer, already checked to hold them
Definition n_tiff.h:76
uint16_t tag
tag number
Definition n_tiff.h:70
N_TIFF_ENTRY * entries
the entries whose values lie inside the buffer, in file order
Definition n_tiff.h:90
uint16_t type
TIFF field type, 1 BYTE to 12 DOUBLE.
Definition n_tiff.h:72
const unsigned char * data
the buffer, borrowed
Definition n_tiff.h:82
uint32_t count
number of values
Definition n_tiff.h:74
int big_endian
1 for "MM" (Motorola, big endian), 0 for "II"
Definition n_tiff.h:86
size_t len
its length
Definition n_tiff.h:84
size_t count
how many
Definition n_tiff.h:92
uint16_t magic
the 16 bit value after the byte order mark
Definition n_tiff.h:88
N_TIFF * n_tiff_parse(const unsigned char *data, size_t len)
Parse the first directory of a TIFF structured buffer.
Definition n_tiff.c:158
size_t n_tiff_count(const N_TIFF *tiff, uint16_t tag)
How many values a tag has.
Definition n_tiff.c:188
size_t n_tiff_get_doubles(const N_TIFF *tiff, uint16_t tag, double *out, size_t max)
Read a numeric tag as doubles.
Definition n_tiff.c:194
const N_TIFF_ENTRY * n_tiff_find(const N_TIFF *tiff, uint16_t tag)
Find an entry by tag.
Definition n_tiff.c:177
int n_tiff_get_ascii(const N_TIFF *tiff, uint16_t tag, char *out, size_t out_len)
Read an ASCII tag.
Definition n_tiff.c:264
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,...
Definition n_tiff.c:94
void n_tiff_free(N_TIFF **tiff)
Release a parse, and set the pointer to NULL.
Definition n_tiff.c:170
The first directory of a TIFF structured buffer.
Definition n_tiff.h:80
One directory entry.
Definition n_tiff.h:68