X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=demo_prior;a=blobdiff_plain;f=libs%2Fimago2%2Fsrc%2Fbyteord.h;fp=libs%2Fimago2%2Fsrc%2Fbyteord.h;h=255202a25ec9b0462128083bfd54b895b9462966;hp=0000000000000000000000000000000000000000;hb=3a9f6854df479d81442273c9d0b133c49c5c8f66;hpb=0b24071f728b7c8550daa1b7aa7c4012cb70ef4c diff --git a/libs/imago2/src/byteord.h b/libs/imago2/src/byteord.h new file mode 100644 index 0000000..255202a --- /dev/null +++ b/libs/imago2/src/byteord.h @@ -0,0 +1,78 @@ +/* +libimago - a multi-format image file input/output library. +Copyright (C) 2010-2017 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published +by the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#ifndef IMAGO_BYTEORD_H_ +#define IMAGO_BYTEORD_H_ + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199900 +#include +#else +#include +#endif +#include "imago2.h" + +#if defined(__i386__) || defined(__ia64__) || defined(WIN32) || \ + (defined(__alpha__) || defined(__alpha)) || \ + defined(__arm__) || \ + (defined(__mips__) && defined(__MIPSEL__)) || \ + defined(__SYMBIAN32__) || \ + defined(__x86_64__) || \ + defined(__LITTLE_ENDIAN__) +/* little endian */ +#define IMAGO_LITTLE_ENDIAN + +#define img_read_int16_le(f) img_read_int16(f) +#define img_write_int16_le(f, v) img_write_int16(f, v) +#define img_read_int16_be(f) img_read_int16_inv(f) +#define img_write_int16_be(f, v) img_write_int16_inv(f, v) +#define img_read_uint16_le(f) img_read_uint16(f) +#define img_write_uint16_le(f, v) img_write_uint16(f, v) +#define img_read_uint16_be(f) img_read_uint16_inv(f) +#define img_write_uint16_be(f, v) img_write_uint16_inv(f, v) + +#define img_read_uint32_be(f) img_read_uint32_inv(f) +#else +/* big endian */ +#define IMAGO_BIG_ENDIAN + +#define img_read_int16_le(f) img_read_int16_inv(f) +#define img_write_int16_le(f, v) img_write_int16_inv(f, v) +#define img_read_int16_be(f) img_read_int16(f) +#define img_write_int16_be(f, v) img_write_int16(f, v) +#define img_read_uint16_le(f) img_read_uint16_inv(f) +#define img_write_uint16_le(f, v) img_write_uint16_inv(f, v) +#define img_read_uint16_be(f) img_read_uint16(f) +#define img_write_uint16_be(f, v) img_write_uint16(f, v) + +#define img_read_uint32_be(f) img_read_uint32(f) +#endif /* endian check */ + +int16_t img_read_int16(struct img_io *io); +int16_t img_read_int16_inv(struct img_io *io); +uint16_t img_read_uint16(struct img_io *io); +uint16_t img_read_uint16_inv(struct img_io *io); + +void img_write_int16(struct img_io *io, int16_t val); +void img_write_int16_inv(struct img_io *io, int16_t val); +void img_write_uint16(struct img_io *io, uint16_t val); +void img_write_uint16_inv(struct img_io *io, uint16_t val); + +uint32_t img_read_uint32(struct img_io *io); +uint32_t img_read_uint32_inv(struct img_io *io); + + +#endif /* IMAGO_BYTEORD_H_ */