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
44
45#ifndef N_TIFF_HEADER_GUARD
46#define N_TIFF_HEADER_GUARD
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
56
57#include <stddef.h>
58#include <stdint.h>
59
61#define N_TIFF_MAGIC 42
63#define N_TIFF_MAGIC_DCP 0x4352
64
66typedef struct N_TIFF_ENTRY {
68 uint16_t tag;
70 uint16_t type;
72 uint32_t count;
74 size_t offset;
76
78typedef struct N_TIFF {
80 const unsigned char* data;
82 size_t len;
86 uint16_t magic;
90 size_t count;
91} N_TIFF;
92
97N_TIFF* n_tiff_parse(const unsigned char* data, size_t len);
98
101void n_tiff_free(N_TIFF** tiff);
102
107const N_TIFF_ENTRY* n_tiff_find(const N_TIFF* tiff, uint16_t tag);
108
113size_t n_tiff_count(const N_TIFF* tiff, uint16_t tag);
114
121size_t n_tiff_get_doubles(const N_TIFF* tiff, uint16_t tag, double* out, size_t max);
122
129int n_tiff_get_ascii(const N_TIFF* tiff, uint16_t tag, char* out, size_t out_len);
130
134
135#ifdef __cplusplus
136}
137#endif
138
139#endif
size_t offset
where the values start in the buffer, already checked to hold them
Definition n_tiff.h:74
uint16_t tag
tag number
Definition n_tiff.h:68
N_TIFF_ENTRY * entries
the entries whose values lie inside the buffer, in file order
Definition n_tiff.h:88
uint16_t type
TIFF field type, 1 BYTE to 12 DOUBLE.
Definition n_tiff.h:70
const unsigned char * data
the buffer, borrowed
Definition n_tiff.h:80
uint32_t count
number of values
Definition n_tiff.h:72
int big_endian
1 for "MM" (Motorola, big endian), 0 for "II"
Definition n_tiff.h:84
size_t len
its length
Definition n_tiff.h:82
size_t count
how many
Definition n_tiff.h:90
uint16_t magic
the 16 bit value after the byte order mark
Definition n_tiff.h:86
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:94
size_t n_tiff_count(const N_TIFF *tiff, uint16_t tag)
How many values a tag has.
Definition n_tiff.c:178
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:184
const N_TIFF_ENTRY * n_tiff_find(const N_TIFF *tiff, uint16_t tag)
Find an entry by tag.
Definition n_tiff.c:167
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:254
void n_tiff_free(N_TIFF **tiff)
Release a parse, and set the pointer to NULL.
Definition n_tiff.c:160
The first directory of a TIFF structured buffer.
Definition n_tiff.h:78
One directory entry.
Definition n_tiff.h:66