+#include "lib/mempool.h"
+
+/* image.c */
+
+/* error handling */
+
+enum image_error {
+ IMAGE_ERR_OK = 0,
+ IMAGE_ERR_UNSPECIFIED,
+ IMAGE_ERR_NOT_IMPLEMENTED,
+ IMAGE_ERR_INVALID_DIMENSIONS,
+ IMAGE_ERR_INVALID_FILE_FORMAT,
+ IMAGE_ERR_INVALID_PIXEL_FORMAT,
+ IMAGE_ERR_READ_FAILED,
+ IMAGE_ERR_WRITE_FAILED,
+ IMAGE_ERR_MAX
+};
+
+struct image_thread {
+ byte *err_msg;
+ enum image_error err_code;
+ struct mempool *pool;
+};
+
+void image_thread_init(struct image_thread *thread);
+void image_thread_cleanup(struct image_thread *thread);
+
+static inline void
+image_thread_flush(struct image_thread *thread)
+{
+ thread->err_code = 0;
+ thread->err_msg = NULL;
+ mp_flush(thread->pool);
+}
+
+static inline void
+image_thread_err(struct image_thread *thread, uns code, char *msg)
+{
+ thread->err_code = code;
+ thread->err_msg = (byte *)msg;
+}
+
+static inline void
+image_thread_err_dup(struct image_thread *thread, uns code, char *msg)
+{
+ thread->err_code = code;
+ thread->err_msg = mp_strdup(thread->pool, msg);
+}
+
+void image_thread_err_format(struct image_thread *thread, uns code, char *msg, ...);
+
+/* basic image manupulation */
+
+#define IMAGE_MAX_SIZE 0xffffU /* maximum number of cols/rows, must be <(1<<16) */
+#define IMAGE_SSE_ALIGN_SIZE (MAX(16, sizeof(uns)))
+
+enum color_space {
+ COLOR_SPACE_UNKNOWN,
+ COLOR_SPACE_GRAYSCALE,
+ COLOR_SPACE_RGB,
+ COLOR_SPACE_MAX
+};
+