textures, overlay images, libimago
[demo_prior] / libs / imago2 / src / byteord.h
1 /*
2 libimago - a multi-format image file input/output library.
3 Copyright (C) 2010-2017 John Tsiombikas <nuclear@member.fsf.org>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published
7 by the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef IMAGO_BYTEORD_H_
19 #define IMAGO_BYTEORD_H_
20
21 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199900
22 #include <stdint.h>
23 #else
24 #include <sys/types.h>
25 #endif
26 #include "imago2.h"
27
28 #if  defined(__i386__) || defined(__ia64__) || defined(WIN32) || \
29     (defined(__alpha__) || defined(__alpha)) || \
30      defined(__arm__) || \
31     (defined(__mips__) && defined(__MIPSEL__)) || \
32      defined(__SYMBIAN32__) || \
33      defined(__x86_64__) || \
34      defined(__LITTLE_ENDIAN__)
35 /* little endian */
36 #define IMAGO_LITTLE_ENDIAN
37
38 #define img_read_int16_le(f)            img_read_int16(f)
39 #define img_write_int16_le(f, v)        img_write_int16(f, v)
40 #define img_read_int16_be(f)            img_read_int16_inv(f)
41 #define img_write_int16_be(f, v)        img_write_int16_inv(f, v)
42 #define img_read_uint16_le(f)           img_read_uint16(f)
43 #define img_write_uint16_le(f, v)       img_write_uint16(f, v)
44 #define img_read_uint16_be(f)           img_read_uint16_inv(f)
45 #define img_write_uint16_be(f, v)       img_write_uint16_inv(f, v)
46
47 #define img_read_uint32_be(f)           img_read_uint32_inv(f)
48 #else
49 /* big endian */
50 #define IMAGO_BIG_ENDIAN
51
52 #define img_read_int16_le(f)            img_read_int16_inv(f)
53 #define img_write_int16_le(f, v)        img_write_int16_inv(f, v)
54 #define img_read_int16_be(f)            img_read_int16(f)
55 #define img_write_int16_be(f, v)        img_write_int16(f, v)
56 #define img_read_uint16_le(f)           img_read_uint16_inv(f)
57 #define img_write_uint16_le(f, v)       img_write_uint16_inv(f, v)
58 #define img_read_uint16_be(f)           img_read_uint16(f)
59 #define img_write_uint16_be(f, v)       img_write_uint16(f, v)
60
61 #define img_read_uint32_be(f)           img_read_uint32(f)
62 #endif  /* endian check */
63
64 int16_t img_read_int16(struct img_io *io);
65 int16_t img_read_int16_inv(struct img_io *io);
66 uint16_t img_read_uint16(struct img_io *io);
67 uint16_t img_read_uint16_inv(struct img_io *io);
68
69 void img_write_int16(struct img_io *io, int16_t val);
70 void img_write_int16_inv(struct img_io *io, int16_t val);
71 void img_write_uint16(struct img_io *io, uint16_t val);
72 void img_write_uint16_inv(struct img_io *io, uint16_t val);
73
74 uint32_t img_read_uint32(struct img_io *io);
75 uint32_t img_read_uint32_inv(struct img_io *io);
76
77
78 #endif  /* IMAGO_BYTEORD_H_ */