]> mj.ucw.cz Git - libucw.git/commitdiff
missing file
authorPavel Charvat <pavel.charvat@netcentrum.cz>
Thu, 27 Jul 2006 08:47:54 +0000 (10:47 +0200)
committerPavel Charvat <pavel.charvat@netcentrum.cz>
Thu, 27 Jul 2006 08:47:54 +0000 (10:47 +0200)
images/io-main.h [new file with mode: 0644]

diff --git a/images/io-main.h b/images/io-main.h
new file mode 100644 (file)
index 0000000..ed4f853
--- /dev/null
@@ -0,0 +1,72 @@
+#ifndef _IMAGES_IO_MAIN_H
+#define _IMAGES_IO_MAIN_H
+
+int libjpeg_read_header(struct image_io *io);
+int libjpeg_read_data(struct image_io *io);
+int libjpeg_write(struct image_io *io);
+
+int libpng_read_header(struct image_io *io);
+int libpng_read_data(struct image_io *io);
+int libpng_write(struct image_io *io);
+
+int libungif_read_header(struct image_io *io);
+int libungif_read_data(struct image_io *io);
+
+int libmagick_read_header(struct image_io *io);
+int libmagick_read_data(struct image_io *io);
+int libmagick_write(struct image_io *io);
+
+struct image_io_read_data_internals {
+  struct image *image;
+  int need_scale;
+  int need_destroy;
+};
+
+static inline struct image *
+image_io_read_data_prepare(struct image_io_read_data_internals *rdi, struct image_io *io, uns cols, uns rows)
+{
+  rdi->need_scale = io->cols != cols | io->rows != rows;
+  rdi->need_destroy = rdi->need_scale || !io->pool;
+  return rdi->image = rdi->need_scale ?
+    image_new(io->thread, cols, rows, io->flags & IMAGE_CHANNELS_FORMAT, NULL) :
+    image_new(io->thread, io->cols, io->rows, io->flags & IMAGE_IO_IMAGE_FLAGS, io->pool);
+}
+
+static inline int
+image_io_read_data_finish(struct image_io_read_data_internals *rdi, struct image_io *io)
+{
+  if (rdi->need_scale)
+    {
+      struct image *img = image_new(io->thread, io->cols, io->rows, io->flags & IMAGE_IO_IMAGE_FLAGS, io->pool);
+      if (unlikely(!img))
+        {
+         if (rdi->need_destroy)
+           image_destroy(rdi->image);
+         return 0;
+       }
+      if (unlikely(!image_scale(io->thread, img, rdi->image)))
+        {
+          image_destroy(rdi->image);
+         if (!io->pool)
+           image_destroy(img);
+         return 0;
+       }
+      io->image = img;
+      io->image_destroy = !io->pool;
+    }
+  else
+    {
+      io->image = rdi->image;
+      io->image_destroy = rdi->need_destroy;
+    }
+  return 1;
+}
+
+static inline void
+image_io_read_data_break(struct image_io_read_data_internals *rdi, struct image_io *io UNUSED)
+{
+  if (rdi->need_destroy)
+    image_destroy(rdi->image);
+}
+
+#endif