2009-04-30 13:00:22 -04:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
|
|
|
* An object oriented GL/GLES Abstraction/Utility Layer
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
|
|
|
*
|
|
|
|
* 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 2 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
|
2010-03-01 07:56:10 -05:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
2009-04-30 13:00:22 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
|
|
|
#error "Only <cogl/cogl.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __COGL_BITMAP_H__
|
|
|
|
#define __COGL_BITMAP_H__
|
|
|
|
|
|
|
|
#include <cogl/cogl-types.h>
|
2011-07-25 17:14:08 -04:00
|
|
|
#include <cogl/cogl-buffer.h>
|
2009-04-30 13:00:22 -04:00
|
|
|
|
2009-05-06 05:35:28 -04:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2010-05-27 19:51:40 -04:00
|
|
|
typedef struct _CoglBitmap CoglBitmap;
|
|
|
|
|
2009-04-30 13:00:22 -04:00
|
|
|
/**
|
|
|
|
* SECTION:cogl-bitmap
|
2009-11-19 08:29:02 -05:00
|
|
|
* @short_description: Fuctions for loading images
|
2009-04-30 13:00:22 -04:00
|
|
|
*
|
|
|
|
* Cogl allows loading image data into memory as CoglBitmaps without
|
|
|
|
* loading them immediately into GPU textures.
|
2009-11-19 08:29:02 -05:00
|
|
|
*
|
|
|
|
* #CoglBitmap is available since Cogl 1.0
|
2009-04-30 13:00:22 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_bitmap_new_from_file:
|
|
|
|
* @filename: the file to load.
|
|
|
|
* @error: a #GError or %NULL.
|
|
|
|
*
|
2009-06-10 07:50:45 -04:00
|
|
|
* Loads an image file from disk. This function can be safely called from
|
2009-04-30 13:00:22 -04:00
|
|
|
* within a thread.
|
|
|
|
*
|
2010-05-27 19:51:40 -04:00
|
|
|
* Return value: a #CoglBitmap to the new loaded image data, or
|
|
|
|
* %NULL if loading the image failed.
|
2009-04-30 13:00:22 -04:00
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
2010-05-27 19:51:40 -04:00
|
|
|
CoglBitmap *
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-09 20:57:32 -05:00
|
|
|
cogl_bitmap_new_from_file (const char *filename,
|
|
|
|
GError **error);
|
2009-04-30 13:00:22 -04:00
|
|
|
|
2011-07-25 17:14:08 -04:00
|
|
|
#if defined (COGL_ENABLE_EXPERIMENTAL_API)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_bitmap_new_from_buffer:
|
|
|
|
* @buffer: A #CoglBuffer containing image data
|
|
|
|
* @format: The #CoglPixelFormat defining the format of the image data
|
|
|
|
* in the given @buffer.
|
|
|
|
* @width: The width of the image data in the given @buffer.
|
|
|
|
* @height: The height of the image data in the given @buffer.
|
|
|
|
* @rowstride: The rowstride in bytes of the image data in the given @buffer.
|
|
|
|
* @offset: The offset into the given @buffer to the first pixel that
|
|
|
|
* should be considered part of the #CoglBitmap.
|
|
|
|
*
|
|
|
|
* Wraps some image data that has been uploaded into a #CoglBuffer as
|
|
|
|
* a #CoglBitmap. The data is not copied in this process.
|
|
|
|
*
|
|
|
|
* Return value: a #CoglBitmap encapsulating the given @buffer.
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
* Stability: unstable
|
|
|
|
*/
|
|
|
|
CoglBitmap *
|
|
|
|
cogl_bitmap_new_from_buffer (CoglBuffer *buffer,
|
|
|
|
CoglPixelFormat format,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
int rowstride,
|
|
|
|
int offset);
|
|
|
|
#endif
|
|
|
|
|
2009-04-30 13:00:22 -04:00
|
|
|
/**
|
|
|
|
* cogl_bitmap_get_size_from_file:
|
|
|
|
* @filename: the file to check
|
2009-11-19 08:29:02 -05:00
|
|
|
* @width: (out): return location for the bitmap width, or %NULL
|
|
|
|
* @height: (out): return location for the bitmap height, or %NULL
|
2009-04-30 13:00:22 -04:00
|
|
|
*
|
|
|
|
* Parses an image file enough to extract the width and height
|
|
|
|
* of the bitmap.
|
|
|
|
*
|
2009-11-19 08:29:02 -05:00
|
|
|
* Return value: %TRUE if the image was successfully parsed
|
2009-06-10 07:50:45 -04:00
|
|
|
*
|
2009-04-30 13:00:22 -04:00
|
|
|
* Since: 1.0
|
|
|
|
*/
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-09 20:57:32 -05:00
|
|
|
gboolean
|
|
|
|
cogl_bitmap_get_size_from_file (const char *filename,
|
|
|
|
int *width,
|
|
|
|
int *height);
|
2009-04-30 13:00:22 -04:00
|
|
|
|
2009-11-11 05:32:39 -05:00
|
|
|
/**
|
|
|
|
* cogl_is_bitmap:
|
|
|
|
* @handle: a #CoglHandle for a bitmap
|
|
|
|
*
|
|
|
|
* Checks whether @handle is a #CoglHandle for a bitmap
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the passed handle represents a bitmap,
|
|
|
|
* and %FALSE otherwise
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-09 20:57:32 -05:00
|
|
|
gboolean
|
|
|
|
cogl_is_bitmap (CoglHandle handle);
|
2009-11-11 05:32:39 -05:00
|
|
|
|
2010-07-01 16:49:16 -04:00
|
|
|
/**
|
|
|
|
* COGL_BITMAP_ERROR:
|
|
|
|
*
|
|
|
|
* #GError domain for bitmap errors.
|
|
|
|
*
|
|
|
|
* Since: 1.4
|
|
|
|
*/
|
|
|
|
#define COGL_BITMAP_ERROR (cogl_bitmap_error_quark ())
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CoglBitmapError:
|
|
|
|
* @COGL_BITMAP_ERROR_FAILED: Generic failure code, something went
|
|
|
|
* wrong.
|
2010-12-22 04:42:41 -05:00
|
|
|
* @COGL_BITMAP_ERROR_UNKNOWN_TYPE: Unknown image type.
|
|
|
|
* @COGL_BITMAP_ERROR_CORRUPT_IMAGE: An image file was broken somehow.
|
2010-07-01 16:49:16 -04:00
|
|
|
*
|
|
|
|
* Error codes that can be thrown when performing bitmap
|
|
|
|
* operations. Note that gdk_pixbuf_new_from_file() can also throw
|
|
|
|
* errors directly from the underlying image loading library. For
|
|
|
|
* example, if GdkPixbuf is used then errors #GdkPixbufError<!-- -->s
|
|
|
|
* will be used directly.
|
|
|
|
*
|
|
|
|
* Since: 1.4
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
COGL_BITMAP_ERROR_FAILED,
|
|
|
|
COGL_BITMAP_ERROR_UNKNOWN_TYPE,
|
|
|
|
COGL_BITMAP_ERROR_CORRUPT_IMAGE
|
|
|
|
} CoglBitmapError;
|
|
|
|
|
|
|
|
GQuark cogl_bitmap_error_quark (void);
|
|
|
|
|
2009-04-30 13:00:22 -04:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __COGL_BITMAP_H__ */
|