added scr_lvled, a bunch of libraries, and improved framework code
[raydungeon] / libs / imago / src / byteord.h
diff --git a/libs/imago/src/byteord.h b/libs/imago/src/byteord.h
new file mode 100644 (file)
index 0000000..144165b
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+libimago - a multi-format image file input/output library.
+Copyright (C) 2010-2017 John Tsiombikas <nuclear@member.fsf.org>
+
+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 <http://www.gnu.org/licenses/>.
+*/
+#ifndef IMAGO_BYTEORD_H_
+#define IMAGO_BYTEORD_H_
+
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199900) || \
+       (defined(_MSC_VER) && _MSC_VER >= 1600) || \
+       (defined(__WATCOMC__) && __WATCOMC__ >= 1200)
+#include <stdint.h>
+#else
+#include <sys/types.h>
+#endif
+
+#if defined(__DOS__) && defined(__WATCOMC__) && __WATCOMC__ < 1200
+typedef signed char int8_t;
+typedef unsigned char uint8_t;
+typedef short int16_t;
+typedef unsigned short uint16_t;
+typedef long int32_t;
+typedef unsigned long uint32_t;
+typedef long intptr_t;
+typedef unsigned long uintptr_t;
+#endif
+
+#if defined(_MSC_VER) && (_MSC_VER < 1600)
+typedef signed __int8 int8_t;
+typedef unsigned __int8 uint8_t;
+typedef __int16 int16_t;
+typedef unsigned __int16 uint16_t;
+typedef __int32 int32_t;
+typedef unsigned __int32 uint32_t;
+typedef long intptr_t;
+typedef unsigned long uintptr_t;
+#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_ */