babl r390 - in trunk: . babl babl/base



Author: martinn
Date: Sat Jan 24 08:52:04 2009
New Revision: 390
URL: http://svn.gnome.org/viewvc/babl?rev=390&view=rev

Log:
Do a complete overhaul of the babl API.

* babl/babl.h: Instead of including subsystem headers, declare the
functions part of the API directly in the header. The public
types, macros and the version header is still pulled in as
includes but with inclusion guards that prevent them from being
included separately by clients. Notable things removed from the
API is internal class functions and the class instance structs.

(babl_format_has_alpha)
(babl_format_get_bytes_per_pixel)
(babl_format_get_num_of_components)
(babl_format_get_type): New getters to allow the Babl union to
become opaque for clients.

* babl/babl-types.h: New file with public types. Currently only
the opaque Babl union and the linear and planar conversion
function prototypes (which are not used in the API due to the use
of varags but still part of the API for reference) are there. Make
sure it's only included indirectly through babl.h.

* babl/babl-macros.h
* babl/babl-version.h.in: Make sure these are not included
directly, only indirectly through babl.h.

* babl/babl-main.h: Removed, function declarations are in babl.h
now.

* babl/babl-internal.h: Include the headers we now consider
internal, mostly the different class headers.

* babl/babl-class.h: The "named class" function declarations are
now in the public header so move them away from this internal
header.

* babl/babl-image.h
* babl/babl-format.h
* babl/babl-fish.h
* babl/babl-extension.h
* babl/babl-conversion.h
* babl/babl-component.h
* babl/babl-classes.h
* babl/babl-introspect.h
* babl/babl-sampling.h
* babl/babl-model.h
* babl/babl-type.h: Adapt to above changes, move relevant things to babl.h

* babl/base/formats.c
* babl/base/model-gray.c
* babl/base/model-rgb.c
* babl/base/model-ycbcr.c
* babl/base/type-float.c: Explicitly #include "babl-classes.h".

* babl/babl-internal.c: s/babl_name/babl_get_name/

* babl/babl-format.c
(babl_format_has_alpha)
(babl_format_get_bytes_per_pixel)
(babl_format_get_num_of_components)
(babl_format_get_type): Implement these.

* babl/Makefile.am: Don't install the now internal headers and
add, remove and install the other headers according to above
changes.


Added:
   trunk/babl/babl-types.h
Modified:
   trunk/ChangeLog
   trunk/babl/Makefile.am
   trunk/babl/babl-class.h
   trunk/babl/babl-classes.h
   trunk/babl/babl-component.h
   trunk/babl/babl-conversion.h
   trunk/babl/babl-extension.h
   trunk/babl/babl-fish.h
   trunk/babl/babl-format.c
   trunk/babl/babl-format.h
   trunk/babl/babl-image.h
   trunk/babl/babl-internal.c
   trunk/babl/babl-internal.h
   trunk/babl/babl-introspect.h
   trunk/babl/babl-macros.h
   trunk/babl/babl-main.h
   trunk/babl/babl-model.h
   trunk/babl/babl-sampling.h
   trunk/babl/babl-type.h
   trunk/babl/babl-version.h.in
   trunk/babl/babl.h
   trunk/babl/base/formats.c
   trunk/babl/base/model-gray.c
   trunk/babl/base/model-rgb.c
   trunk/babl/base/model-ycbcr.c
   trunk/babl/base/type-float.c

Modified: trunk/babl/Makefile.am
==============================================================================
--- trunk/babl/Makefile.am	(original)
+++ trunk/babl/Makefile.am	Sat Jan 24 08:52:04 2009
@@ -41,8 +41,8 @@
 	babl-internal.h			\
 	babl-introspect.h		\
 	babl-macros.h			\
-	babl-main.h			\
 	babl-memory.h			\
+	babl-types.h                    \
 	babl-util.h			\
 	babl.h				\
 	babl-list.h			\
@@ -51,22 +51,10 @@
 
 library_includedir=$(includedir)/babl-$(BABL_API_VERSION)/babl
 library_include_HEADERS =		\
-	babl.h				\
-	babl-class.h			\
-	babl-classes.h			\
-	babl-component.h		\
-	babl-conversion.h		\
-	babl-extension.h		\
-	babl-fish.h			\
-	babl-format.h			\
-	babl-image.h			\
-	babl-introspect.h		\
 	babl-macros.h			\
-	babl-main.h			\
-	babl-model.h			\
-	babl-sampling.h 		\
-	babl-type.h                     \
-	babl-version.h
+	babl-types.h                    \
+	babl-version.h			\
+	babl.h
 
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/babl/base
 

Modified: trunk/babl/babl-class.h
==============================================================================
--- trunk/babl/babl-class.h	(original)
+++ trunk/babl/babl-class.h	Sat Jan 24 08:52:04 2009
@@ -19,13 +19,12 @@
 #ifndef _BABL_CLASS_H
 #define _BABL_CLASS_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
+#include "babl.h"
 
-typedef int BablClassType;
 
-typedef union _Babl Babl;
+typedef struct _BablList BablList;
+
+typedef int BablClassType;
 
 typedef int  (*BablEachFunction) (Babl *entry,
                                   void *data);
@@ -42,18 +41,17 @@
 void   babl_##klass##_class_for_each (BablEachFunction  each_fun,  \
                                       void             *user_data)
 
-/* creates a class that has a specific name connected to it, that
- * also allows defining a new instance. These classes share common
- * functionality with the non_name classes but have two extra methods,
- * the means to lookup by name, as well as to create new named objects
- * that later can be looked up.
+/* If a class is declared as a "named class" it means it is a class
+ * that has a specific name connected to it, that also allows defining
+ * a new instance. These classes share common functionality with the
+ * non_name classes but have two extra methods, the means to lookup by
+ * name, as well as to create new named objects that later can be
+ * looked up. These methods are babl_klass() babl_klass_new() but they
+ * are declared outside of this macro.
  */
-#define BABL_NAMED_CLASS_DECLARE(klass)                        \
-                                                               \
-BABL_CLASS_DECLARE (klass);                                    \
-Babl * babl_##klass             (const char       *name);      \
-Babl * babl_##klass##_new       (void             *first_arg,  \
-                                  ...) BABL_ARG_NULL_TERMINATED
+#define BABL_NAMED_CLASS_DECLARE(klass) \
+BABL_CLASS_DECLARE (klass)
+
 
 /* common header for any item inserted into database, the actual
  * implementation of babl-instance is in babl-internal

Modified: trunk/babl/babl-classes.h
==============================================================================
--- trunk/babl/babl-classes.h	(original)
+++ trunk/babl/babl-classes.h	Sat Jan 24 08:52:04 2009
@@ -19,10 +19,7 @@
 #ifndef _BABL_CLASSES_H
 #define _BABL_CLASSES_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
-
+#include "babl-class.h"
 
 /* magic number used at the start of all babl objects, used to do
  * differentiation in polymorphic functions. (as well as manual type

Modified: trunk/babl/babl-component.h
==============================================================================
--- trunk/babl/babl-component.h	(original)
+++ trunk/babl/babl-component.h	Sat Jan 24 08:52:04 2009
@@ -19,18 +19,10 @@
 #ifndef _BABL_COMPONENT_H
 #define _BABL_COMPONENT_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
-
 
 /****************************************************************/
 /* BablComponent */
 BABL_NAMED_CLASS_DECLARE (component);
-/*
- * Babl * babl_component_new (const char *name,
- *                            NULL);
- */
 
 
 typedef struct

Modified: trunk/babl/babl-conversion.h
==============================================================================
--- trunk/babl/babl-conversion.h	(original)
+++ trunk/babl/babl-conversion.h	Sat Jan 24 08:52:04 2009
@@ -19,26 +19,11 @@
 #ifndef _BABL_CONVERSION_H
 #define _BABL_CONVERSION_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
-
-/****************************************************************/
-/* BablConversion */
 BABL_NAMED_CLASS_DECLARE (conversion);
-/*
- * Babl * babl_conversion_new (<BablFormat *source, BablFormat *destination|
- *                              BablModel  *source, BablModel  *destination|
- *                              BablType   *source, BablType   *destination>,
- *                             <"linear"|"planar">, BablConversionFunc conv_func,
- *                              NULL);
- */
+
+Babl * babl_conversion (const char *name);
 
 
-/* Type and Format */
-typedef long (*BablFuncLinear)    (char  *src,
-                                   char  *dst,
-                                   long   n);
 
 /* Signature of functions registered for reference type
  * conversions,
@@ -49,14 +34,6 @@
                                    int    dst_pitch,
                                    long   n);
 
-/* TypePlanar,ModelPlanar and FormatPlanar */
-typedef long (*BablFuncPlanar)    (int    src_bands,
-                                   char  *src[],
-                                   int    src_pitch[],
-                                   int    dst_bands,
-                                   char  *dst[],
-                                   int    dst_pitch[],
-                                   long   n);
 
 typedef struct
 BablConversion {

Modified: trunk/babl/babl-extension.h
==============================================================================
--- trunk/babl/babl-extension.h	(original)
+++ trunk/babl/babl-extension.h	Sat Jan 24 08:52:04 2009
@@ -19,9 +19,6 @@
 #ifndef _BABL_EXTENSION_H
 #define _BABL_EXTENSION_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
 
 /****************************************************************/
 /* BablExtension */
@@ -30,6 +27,8 @@
  * BablExtension objects are only used internally in babl.
  */
 
+Babl * babl_extension (const char *name);
+
 
 typedef struct
 {

Modified: trunk/babl/babl-fish.h
==============================================================================
--- trunk/babl/babl-fish.h	(original)
+++ trunk/babl/babl-fish.h	Sat Jan 24 08:52:04 2009
@@ -19,27 +19,10 @@
 #ifndef _BABL_FISH_H
 #define _BABL_FISH_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h 
-#endif
 
 /****************************************************************/
 /* BablFish */
 BABL_CLASS_DECLARE (fish);
-/*  Create a babl fish capable of converting from source_format to
- *  destination_format, source and destination can be
- *  either strings with the names of the formats or BablFormat objects.
- */
-Babl * babl_fish       (const void *source_format,
-                        const void *destination_format);
-
-/** Process n pixels from source to destination using babl_fish,
- *  returns number of pixels converted. 
- */
-long   babl_process    (Babl *babl_fish,
-                        void *source,
-                        void *destination,
-                        long  n);
 
 /* BablFish, common base class for various fishes.
  */

Modified: trunk/babl/babl-format.c
==============================================================================
--- trunk/babl/babl-format.c	(original)
+++ trunk/babl/babl-format.c	Sat Jan 24 08:52:04 2009
@@ -328,6 +328,59 @@
   return babl_db_count (db);
 }
 
+int
+babl_format_has_alpha (const Babl *format)
+{
+  int i;
+  int has_alpha = 0;
+
+  for (i = 0; i < babl_format_get_num_of_components (format); i++)
+    {
+      if (format->format.component[i]->alpha)
+        {
+          has_alpha = 1;
+          break;
+        }
+    }
+
+  return has_alpha;
+}
+
+int
+babl_format_get_bytes_per_pixel (const Babl *format)
+{
+  if (format->class_type == BABL_FORMAT)
+    {
+      return format->format.bytes_per_pixel;
+    }
+
+  return 0;
+}
+
+int
+babl_format_get_num_of_components (const Babl *format)
+{
+  if (format->class_type == BABL_FORMAT)
+    {
+      return format->format.components;
+    }
+
+  return 0;
+}
+
+Babl *
+babl_format_get_type (const Babl *format,
+                      int         component_index)
+{
+  if (format->class_type == BABL_FORMAT &&
+      component_index >= 0 &&
+      component_index < format->format.components)
+    {
+      return (Babl *)format->format.type[component_index];
+    }
+
+  return NULL;
+}
 
 Babl *
 babl_format_with_model_as_type (Babl *model,

Modified: trunk/babl/babl-format.h
==============================================================================
--- trunk/babl/babl-format.h	(original)
+++ trunk/babl/babl-format.h	Sat Jan 24 08:52:04 2009
@@ -19,31 +19,7 @@
 #ifndef _BABL_FORMAT_H
 #define _BABL_FORMAT_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
-
-/****************************************************************/
-/* BablFormat */
 BABL_NAMED_CLASS_DECLARE (format);
-/*
- * Babl * babl_format_new (["name", const char *name,]
- *                          BablModel          *model,
- *                         [BablType           *type,]
- *                         [BablSampling,      *sampling,]
- *                          BablComponent      *component1,
- *                        [[BablType           *type,]
- *                         [BablSampling       *sampling,]
- *                          BablComponent      *componentN,
- *                        ...]
- *                          ["planar",]
- *                          NULL);
- *
- * Provided BablType and|or BablSampling is valid for the following
- * components as well. If no name is provided a (long) descriptive
- * name is used.
- */
-
 
 typedef struct
 {

Modified: trunk/babl/babl-image.h
==============================================================================
--- trunk/babl/babl-image.h	(original)
+++ trunk/babl/babl-image.h	Sat Jan 24 08:52:04 2009
@@ -19,9 +19,6 @@
 #ifndef _BABL_IMAGE_H
 #define _BABL_IMAGE_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
 
 /****************************************************************/
 /* BablImage */

Modified: trunk/babl/babl-internal.c
==============================================================================
--- trunk/babl/babl-internal.c	(original)
+++ trunk/babl/babl-internal.c	Sat Jan 24 08:52:04 2009
@@ -132,7 +132,7 @@
 
 
 const char *
-babl_name (const Babl *babl)
+babl_get_name (const Babl *babl)
 {
   babl_assert (BABL_IS_BABL (babl));
   return babl->instance.name;

Modified: trunk/babl/babl-internal.h
==============================================================================
--- trunk/babl/babl-internal.h	(original)
+++ trunk/babl/babl-internal.h	Sat Jan 24 08:52:04 2009
@@ -38,6 +38,9 @@
 
 #include "config.h"
 
+#include "babl-class.h"
+#include "babl-classes.h"
+#include "babl-introspect.h"
 #include "babl-list.h"
 #include "babl-hash-table.h"
 #include "babl-db.h"

Modified: trunk/babl/babl-introspect.h
==============================================================================
--- trunk/babl/babl-introspect.h	(original)
+++ trunk/babl/babl-introspect.h	Sat Jan 24 08:52:04 2009
@@ -19,20 +19,6 @@
 #ifndef _BABL_INTROSPECT_H
 #define _BABL_INTROSPECT_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
-
-
-/**
- * babl_name:
- *
- * Return a string decsribing a BablInstance, might work better than
- * babl->instance.name when a good human readable name is desired.
- *
- * Returns: a name describing the instance.
- */
-const char * babl_name       (const Babl *babl);
 
 void         babl_introspect (Babl       *babl); /* introspect a given BablObject     */
 

Modified: trunk/babl/babl-macros.h
==============================================================================
--- trunk/babl/babl-macros.h	(original)
+++ trunk/babl/babl-macros.h	Sat Jan 24 08:52:04 2009
@@ -19,10 +19,11 @@
 #ifndef _BABL_MACROS_H
 #define _BABL_MACROS_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
+#ifndef BABL_INSIDE_BABL_H
+#error "babl-version.h must not be included directly, include babl.h instead."
 #endif
 
+
 #if     __GNUC__ >= 4
 #define BABL_ARG_NULL_TERMINATED __attribute__((__sentinel__))
 #else

Modified: trunk/babl/babl-main.h
==============================================================================
--- trunk/babl/babl-main.h	(original)
+++ trunk/babl/babl-main.h	Sat Jan 24 08:52:04 2009
@@ -1,46 +0,0 @@
-/* babl - dynamically extendable universal pixel conversion library.
- * Copyright (C) 2005-2008, Ãyvind KolÃs and others.
- *
- * 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/>.
- */
-
-#ifndef _BABL_MAIN_H
-#define _BABL_MAIN_H
-
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
-
-/**
- * Initialize the babl library
- */
-void   babl_init       (void);
-
-/**
- * Deinitialize the babl library (frees any resources used, if the
- * number of calls to babl_exit() is is equal to the number of calls
- * to babl_init()
- */
-void   babl_exit       (void);
-
-
-#ifndef BABL_DISABLE_DEPRECATED
-
-#define babl_destroy babl_exit
-
-#endif /* BABL_DISABLE_DEPRECATED */
-
-
-#endif

Modified: trunk/babl/babl-model.h
==============================================================================
--- trunk/babl/babl-model.h	(original)
+++ trunk/babl/babl-model.h	Sat Jan 24 08:52:04 2009
@@ -19,24 +19,7 @@
 #ifndef _BABL_MODEL_H
 #define _BABL_MODEL_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
-
-/****************************************************************/
-/* BablModel */
 BABL_NAMED_CLASS_DECLARE (model);
-/*
- * Babl * babl_model_new (["name", const char *name,]
- *                        BablComponent *component1,
- *                       [BablComponent *componentN, ...]
- *                        NULL);
- *
- * If no name is provided a name is generated by concatenating the
- * name of all the involved components.
- *
- */
-
 
 typedef struct
 {

Modified: trunk/babl/babl-sampling.h
==============================================================================
--- trunk/babl/babl-sampling.h	(original)
+++ trunk/babl/babl-sampling.h	Sat Jan 24 08:52:04 2009
@@ -19,16 +19,8 @@
 #ifndef _BABL_SAMPLING_H
 #define _BABL_SAMPLING_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h 
-#endif
-
-/****************************************************************/
-/* BablSampling */
 BABL_CLASS_DECLARE (sampling);
-/**/
-Babl * babl_sampling       (int horizontal,
-                            int vertical);
+
 typedef struct
 {
   BablInstance     instance;

Modified: trunk/babl/babl-type.h
==============================================================================
--- trunk/babl/babl-type.h	(original)
+++ trunk/babl/babl-type.h	Sat Jan 24 08:52:04 2009
@@ -19,25 +19,7 @@
 #ifndef _BABL_TYPE_H
 #define _BABL_TYPE_H
 
-#ifndef _BABL_H
-#error  this file is only to be included by babl.h
-#endif
-
-/****************************************************************/
-/* BablType */
 BABL_NAMED_CLASS_DECLARE (type);
-/*
- * A data type that babl can have in it's buffers, requires
- * conversions to and from "double" to be registered before
- * passing sanity.
- *
- * Babl * babl_type_new (  const char *name,
- *                         "bits",     int bits,
- *                         ["min_val", double min_val,]
- *                         ["max_val", double max_val,]
- *                         NULL);
- */
-
 
 typedef struct
 {

Added: trunk/babl/babl-types.h
==============================================================================
--- (empty file)
+++ trunk/babl/babl-types.h	Sat Jan 24 08:52:04 2009
@@ -0,0 +1,49 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005-2008, Ãyvind KolÃs and others.
+ *
+ * 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/>.
+ */
+
+#ifndef _BABL_TYPES_H
+#define _BABL_TYPES_H
+
+#ifndef BABL_INSIDE_BABL_H
+#error "babl-version.h must not be included directly, include babl.h instead."
+#endif
+
+
+/**
+ * The babl API is based around polymorphism and almost everything is
+ * a Babl object.
+ */
+typedef union _Babl Babl;
+
+/* Conversion function between linear data of a either a data types or
+ * color formats.
+ */
+typedef long (*BablFuncLinear)    (char  *src,
+                                   char  *dst,
+                                   long   n);
+
+/* TypePlanar,ModelPlanar and FormatPlanar */
+typedef long (*BablFuncPlanar)    (int    src_bands,
+                                   char  *src[],
+                                   int    src_pitch[],
+                                   int    dst_bands,
+                                   char  *dst[],
+                                   int    dst_pitch[],
+                                   long   n);
+
+#endif

Modified: trunk/babl/babl-version.h.in
==============================================================================
--- trunk/babl/babl-version.h.in	(original)
+++ trunk/babl/babl-version.h.in	Sat Jan 24 08:52:04 2009
@@ -19,6 +19,11 @@
 #ifndef _BABL_VERSION_H
 #define _BABL_VERSION_H
 
+#ifndef BABL_INSIDE_BABL_H
+#error "babl-version.h must not be included directly, include babl.h instead."
+#endif
+
+
 /***
  * babl version information
  *

Modified: trunk/babl/babl.h
==============================================================================
--- trunk/babl/babl.h	(original)
+++ trunk/babl/babl.h	Sat Jan 24 08:52:04 2009
@@ -16,27 +16,180 @@
  * <http://www.gnu.org/licenses/>.
  */
 
-/* NOTE! the babl API is polymorphic, it is probably easier to learn
- * it's usage by studying examples than this header file. The public
- * functions are attempted explained anyways.
- */
-
 #ifndef _BABL_H
 #define _BABL_H
 
-#ifdef _BABL_INTERNAL_H
-#error babl.h included after babl-internal.h
-#endif
+#define BABL_INSIDE_BABL_H
+#include "babl-version.h"
+#include "babl-macros.h"
+#include "babl-types.h"
+#undef BABL_INSIDE_BABL_H
 
 
-typedef struct _BablList BablList;
+/**
+ * Initializes the babl library.
+ */
+void         babl_init      (void);
 
-#include "babl-macros.h"
-#include "babl-main.h"
-#include "babl-class.h"
-#include "babl-introspect.h"
-#include "babl-version.h"
-#include "babl-classes.h"
+/**
+ * Deinitializes the babl library and frees any resources used when
+ * matched with the number of calls to babl_init().
+ */
+void         babl_exit      (void);
+
+/**
+ * Returns the babl object representing the data type given by @name
+ * such as for example "u8", "u16" or "float".
+ */
+Babl *       babl_type      (const char *name);
+
+/**
+ * Returns the babl object representing the @horizontal and @vertical
+ * sampling such as for example 2, 2 for the chroma components in
+ * YCbCr.
+ */
+Babl *       babl_sampling  (int horizontal,
+                             int vertical);
+
+/**
+ * Returns the babl object representing the color component given by
+ * @name such as for example "R", "cyan" or "CIE L".
+ */
+Babl *       babl_component (const char *name);
+
+/**
+ * Returns the babl object representing the color model given by @name
+ * such as for example "RGB", "CMYK" or "CIE Lab".
+ */
+Babl *       babl_model     (const char *name);
+
+/**
+ * Returns the babl object representing the color format given by
+ * @name such as for example "RGB u8", "CMYK float" or "CIE Lab u16".
+ */
+Babl *       babl_format    (const char *name);
+
+/*  Create a babl fish capable of converting from source_format to
+ *  destination_format, source and destination can be either strings
+ *  with the names of the formats or Babl-format objects.
+ */
+Babl *       babl_fish      (const void *source_format,
+                             const void *destination_format);
+
+/** Process n pixels from source to destination using babl_fish,
+ *  returns number of pixels converted.
+ */
+long         babl_process   (Babl *babl_fish,
+                             void *source,
+                             void *destination,
+                             long  n);
+
+
+/**
+ * Returns a string decsribing a Babl object.
+ */
+const char * babl_get_name                     (const Babl *babl);
+
+/**
+ * Returns whether the @format has an alpha channel.
+ */
+int          babl_format_has_alpha             (const Babl *format);
+
+/**
+ * Returns the bytes per pixel for a babl color format.
+ */
+int          babl_format_get_bytes_per_pixel   (const Babl *format);
+
+/**
+ * Returns the number of components for the given @format.
+ */
+int          babl_format_get_num_of_components (const Babl *format);
+
+/**
+ * Returns the type in the given @format for the given
+ * @component_index.
+ */
+Babl *       babl_format_get_type              (const Babl *format,
+                                                int         component_index);
+
+
+/**
+ * Defines a new data type in babl. A data type that babl can have in
+ * its buffers requires conversions to and from "double" to be
+ * registered before passing sanity.
+ *
+ *     babl_type_new       (const char *name,
+ *                          "bits",     int bits,
+ *                          ["min_val", double min_val,]
+ *                          ["max_val", double max_val,]
+ *                          NULL);
+ */
+Babl * babl_type_new       (void *first_arg,
+                            ...) BABL_ARG_NULL_TERMINATED;
+
+/**
+ * Defines a new color component with babl.
+ *
+ *     babl_component_new  (const char *name,
+ *                          NULL);
+ */
+Babl * babl_component_new  (void *first_arg,
+                            ...) BABL_ARG_NULL_TERMINATED;
+
+/**
+ * Defines a new color model in babl. If no name is provided a name is
+ * generated by concatenating the name of all the involved components.
+ *
+ *     babl_model_new      (["name", const char *name,]
+ *                          BablComponent *component1,
+ *                          [BablComponent *componentN, ...]
+ *                          NULL);
+ */
+Babl * babl_model_new      (void *first_arg,
+                            ...) BABL_ARG_NULL_TERMINATED;
+
+/**
+ * Defines a new color format in babl. Provided BablType and|or
+ * BablSampling is valid for the following components as well. If no
+ * name is provided a (long) descriptive name is used.
+ *
+ *     babl_format_new     (["name", const char *name,]
+ *                          BablModel          *model,
+ *                          [BablType           *type,]
+ *                          [BablSampling,      *sampling,]
+ *                          BablComponent      *component1,
+ *                          [[BablType           *type,]
+ *                           [BablSampling       *sampling,]
+ *                           BablComponent      *componentN,
+ *                           ...]
+ *                          ["planar",]
+ *                          NULL);
+ */
+Babl * babl_format_new     (void *first_arg,
+                            ...) BABL_ARG_NULL_TERMINATED;
+
+/**
+ * Defines a new conversion between either two formats, two models or
+ * two types in babl.
+ *
+ *     babl_conversion_new (<BablFormat *source, BablFormat *destination|
+ *                          BablModel  *source, BablModel  *destination|
+ *                          BablType   *source, BablType   *destination>,
+ *                          <"linear"|"planar">, <BablFuncLinear | BablFuncPlanar> conv_func,
+ *                          NULL);
+ */
+Babl * babl_conversion_new (void *first_arg,
+                            ...) BABL_ARG_NULL_TERMINATED;
+
+
+/*
+ * Backwards compatibility stuff
+ *
+ * NOTE: will most likely be removed in the first stable release!
+ */
+#ifndef BABL_DISABLE_DEPRECATED
+#define babl_destroy babl_exit
+#endif
 
 
 #endif

Modified: trunk/babl/base/formats.c
==============================================================================
--- trunk/babl/base/formats.c	(original)
+++ trunk/babl/base/formats.c	Sat Jan 24 08:52:04 2009
@@ -18,6 +18,7 @@
 
 #include <stdlib.h>
 
+#include "babl-classes.h"
 #include "babl.h"
 #include "babl-ids.h"
 #include "babl-base.h"

Modified: trunk/babl/base/model-gray.c
==============================================================================
--- trunk/babl/base/model-gray.c	(original)
+++ trunk/babl/base/model-gray.c	Sat Jan 24 08:52:04 2009
@@ -18,6 +18,7 @@
 
 #include <stdlib.h>
 
+#include "babl-classes.h"
 #include "babl.h"
 #include "babl-ids.h"
 #include "util.h"

Modified: trunk/babl/base/model-rgb.c
==============================================================================
--- trunk/babl/base/model-rgb.c	(original)
+++ trunk/babl/base/model-rgb.c	Sat Jan 24 08:52:04 2009
@@ -20,6 +20,7 @@
 #include <math.h>
 
 #include "babl.h"
+#include "babl-classes.h"
 #include "babl-ids.h"
 #include "util.h"
 #include "babl-base.h"

Modified: trunk/babl/base/model-ycbcr.c
==============================================================================
--- trunk/babl/base/model-ycbcr.c	(original)
+++ trunk/babl/base/model-ycbcr.c	Sat Jan 24 08:52:04 2009
@@ -19,7 +19,9 @@
 #include <string.h>
 #include <math.h>
 #include <assert.h>
+
 #include "babl.h"
+#include "babl-classes.h"
 #include "babl-ids.h"
 #include "babl-base.h"
 

Modified: trunk/babl/base/type-float.c
==============================================================================
--- trunk/babl/base/type-float.c	(original)
+++ trunk/babl/base/type-float.c	Sat Jan 24 08:52:04 2009
@@ -20,6 +20,7 @@
 #include <assert.h>
 
 #include "babl.h"
+#include "babl-classes.h"
 #include "babl-ids.h"
 #include "babl-base.h"
 



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