[babl] add bablformats that match the hosts endianness



commit 9e4542ca2b6322c56bc1dc8aa26d091bc5a4a158
Author: Ãyvind KolÃs <pippin gimp org>
Date:   Sat Mar 17 23:54:49 2012 +0000

    add bablformats that match the hosts endianness

 extensions/Makefile.am |    2 +
 extensions/cairo.c     |   86 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 88 insertions(+), 0 deletions(-)
---
diff --git a/extensions/Makefile.am b/extensions/Makefile.am
index e8ad111..fac0123 100644
--- a/extensions/Makefile.am
+++ b/extensions/Makefile.am
@@ -14,6 +14,7 @@ AM_CPPFLAGS = \
 
 extdir = $(libdir)/babl- BABL_API_VERSION@
 ext_LTLIBRARIES = \
+	cairo.la        \
 	CIE.la          \
 	gegl-fixups.la  \
 	gggl-lies.la    \
@@ -22,6 +23,7 @@ ext_LTLIBRARIES = \
 	naive-CMYK.la   \
 	sse-fixups.la
 
+cairo_la_SOURCES = cairo.c
 CIE_la_SOURCES = CIE.c
 gegl_fixups_la_SOURCES = gegl-fixups.c
 gggl_lies_la_SOURCES = gggl-lies.c
diff --git a/extensions/cairo.c b/extensions/cairo.c
new file mode 100644
index 0000000..3a0732f
--- /dev/null
+++ b/extensions/cairo.c
@@ -0,0 +1,86 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2012 Ãyvind KolÃs.
+ *
+ * This library 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 library 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 library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdlib.h>
+#include "babl.h"
+
+int init (void);
+
+int
+init (void)
+{
+  int   testint  = 23;
+  char *testchar = (char*) &testint;
+  int   littleendian = (testchar[0] == 23);
+
+  if (littleendian)
+    {
+      babl_format_new (
+        "name", "cairo-ARGB32",
+        babl_model ("R'aG'aB'aA"),
+        babl_type ("u8"),
+        babl_component ("B'a"),
+        babl_component ("G'a"),
+        babl_component ("R'a"),
+        babl_component ("A"),
+        NULL
+      );
+
+      babl_format_new (
+        "name", "cairo-RGB24",
+        babl_model ("R'G'B'"),
+        babl_type ("u8"),
+        babl_component ("B'"),
+        babl_component ("G'"),
+        babl_component ("R'"),
+        babl_component ("PAD"),
+        NULL
+      );
+    }
+  else
+    {
+      babl_format_new (
+        "name", "cairo-ARGB32",
+        babl_model ("R'G'B'A"),
+        babl_type ("u8"),
+        babl_component ("A"),
+        babl_component ("R'a"),
+        babl_component ("G'a"),
+        babl_component ("B'a"),
+        NULL
+      );
+      babl_format_new (
+        "name", "cairo-RGB24",
+        babl_model ("R'G'B'"),
+        babl_type ("u8"),
+        babl_component ("PAD"),
+        babl_component ("R'"),
+        babl_component ("G'"),
+        babl_component ("B'"),
+        NULL
+      );
+    }
+  babl_format_new (
+    "name", "cairo-A8",
+    babl_model ("YA"),
+    babl_type ("u8"),
+    babl_component ("A"),
+    NULL
+  );
+  return 0;
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]