From 4a41d81ee68d63049e76310edf615a6c83a632a3 Mon Sep 17 00:00:00 2001
From: jylam <jylam@92316355-f0b4-4df1-b90c-862c8a59935f>
Date: Wed, 3 Sep 2008 18:33:46 +0000
Subject: [PATCH]  * Moved accessors to their own file, and added a
 pipi_get_format_name()

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2814 92316355-f0b4-4df1-b90c-862c8a59935f
---
 pipi/Makefile.am    |  1 +
 pipi/accessors.c    | 66 +++++++++++++++++++++++++++++++++++++++++++++
 pipi/codec/opencv.c |  1 +
 pipi/paint/line.c   |  2 +-
 pipi/pipi.h         |  3 +++
 pipi/pixels.c       | 14 ----------
 6 files changed, 72 insertions(+), 15 deletions(-)
 create mode 100644 pipi/accessors.c

diff --git a/pipi/Makefile.am b/pipi/Makefile.am
index 27a5d1b..15d9aba 100644
--- a/pipi/Makefile.am
+++ b/pipi/Makefile.am
@@ -25,6 +25,7 @@ libpipi_la_SOURCES = \
 	resize.c \
 	dither.c \
 	measure.c \
+	accessors.c \
 	$(codec_sources) \
 	$(paint_sources) \
 	$(render_sources) \
diff --git a/pipi/accessors.c b/pipi/accessors.c
new file mode 100644
index 0000000..ab8d983
--- /dev/null
+++ b/pipi/accessors.c
@@ -0,0 +1,66 @@
+/*
+ *  libpipi       Proper image processing implementation library
+ *  Copyright (c) 2004-2008 Sam Hocevar <sam@zoy.org>
+ *                2008 Jean-Yves Lamoureux <jylam@lnxscene.org>
+ *                All Rights Reserved
+ *
+ *  $Id$
+ *
+ *  This library is free software. It comes without any warranty, to
+ *  the extent permitted by applicable law. You can redistribute it
+ *  and/or modify it under the terms of the Do What The Fuck You Want
+ *  To Public License, Version 2, as published by Sam Hocevar. See
+ *  http://sam.zoy.org/wtfpl/COPYING for more details.
+ */
+
+/*
+ * accessors.c: accessors for various informations about images
+ */
+
+#include "config.h"
+#include "common.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <math.h>
+
+#include "pipi.h"
+#include "pipi_internals.h"
+
+int pipi_get_image_width(pipi_image_t *img)
+{
+    return img->w;
+}
+int pipi_get_image_height(pipi_image_t *img)
+{
+    return img->h;
+}
+int pipi_get_image_pitch(pipi_image_t *img)
+{
+    return img->pitch;
+}
+int pipi_get_image_last_modified(pipi_image_t *img)
+{
+    return img->last_modified;
+}
+
+
+
+char formats[][100] =
+{
+    "Unknow",
+    "RGBA_C",
+    "BGR_C",
+    "RGBA_F",
+    "Y_F",
+    "MASK_C",
+    "LOL",
+};
+
+const char* pipi_get_format_name(int format)
+{
+    if(format>PIPI_PIXELS_MAX) return "Invalid";
+    else return formats[format];
+}
diff --git a/pipi/codec/opencv.c b/pipi/codec/opencv.c
index 956025d..95a6b1e 100644
--- a/pipi/codec/opencv.c
+++ b/pipi/codec/opencv.c
@@ -34,6 +34,7 @@
 pipi_image_t *pipi_load_opencv(const char *name)
 {
     pipi_image_t *img;
+
     IplImage *priv = cvLoadImage(name, 1);
 
     if(!priv)
diff --git a/pipi/paint/line.c b/pipi/paint/line.c
index 0e84120..ce79569 100644
--- a/pipi/paint/line.c
+++ b/pipi/paint/line.c
@@ -1,7 +1,7 @@
 /*
  *  libpipi       Proper image processing implementation library
  *  Copyright (c) 2004-2008 Sam Hocevar <sam@zoy.org>
- *                2008 Jean-Yves Lamoureux <jylam@lnxscene.org
+ *                2008 Jean-Yves Lamoureux <jylam@lnxscene.org>
  *                All Rights Reserved
  *
  *  $Id$
diff --git a/pipi/pipi.h b/pipi/pipi.h
index 35abd57..150c2df 100644
--- a/pipi/pipi.h
+++ b/pipi/pipi.h
@@ -122,6 +122,9 @@ extern pipi_pixels_t *pipi_getpixels(pipi_image_t *, pipi_format_t);
 extern int pipi_get_image_width(pipi_image_t *img);
 extern int pipi_get_image_height(pipi_image_t *img);
 extern int pipi_get_image_pitch(pipi_image_t *img);
+extern int pipi_get_image_last_modified(pipi_image_t *img);
+extern const char* pipi_get_format_name(int format);
+
 
 extern double pipi_measure_msd(pipi_image_t *, pipi_image_t *);
 extern double pipi_measure_rmsd(pipi_image_t *, pipi_image_t *);
diff --git a/pipi/pixels.c b/pipi/pixels.c
index 233ae24..533d79e 100644
--- a/pipi/pixels.c
+++ b/pipi/pixels.c
@@ -265,17 +265,3 @@ static void init_tables(void)
 
     done = 1;
 }
-
-/* Accessors */
-int pipi_get_image_width(pipi_image_t *img)
-{
-    return img->w;
-}
-int pipi_get_image_height(pipi_image_t *img)
-{
-    return img->h;
-}
-int pipi_get_image_pitch(pipi_image_t *img)
-{
-    return img->pitch;
-}