4 * A basic GL/GLES Abstraction/Utility Layer
6 * Authored By Matthew Allum <mallum@openedhand.com>
8 * Copyright (C) 2007 OpenedHand
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
26 #ifndef __COGL_BITMAP_H
27 #define __COGL_BITMAP_H
31 #include "cogl-handle.h"
32 #include "cogl-buffer.h"
33 #include "cogl-bitmap.h"
36 * _cogl_bitmap_new_with_malloc_buffer:
37 * @context: A #CoglContext
38 * @width: width of the bitmap in pixels
39 * @height: height of the bitmap in pixels
40 * @format: the format of the pixels the array will store
42 * This is equivalent to cogl_bitmap_new_with_size() except that it
43 * allocated the buffer using g_malloc() instead of creating a
44 * #CoglPixelBuffer. The buffer will be automatically destroyed when
45 * the bitmap is freed.
47 * Return value: a #CoglPixelBuffer representing the newly created array
53 _cogl_bitmap_new_with_malloc_buffer (CoglContext *context,
56 CoglPixelFormat format);
58 /* The idea of this function is that it will create a bitmap that
59 shares the actual data with another bitmap. This is needed for the
60 atlas texture backend because it needs upload a bitmap to a sub
61 texture but override the format so that it ignores the premult
64 _cogl_bitmap_new_shared (CoglBitmap *shared_bmp,
65 CoglPixelFormat format,
71 _cogl_bitmap_convert (CoglBitmap *bmp,
72 CoglPixelFormat dst_format);
75 _cogl_bitmap_convert_into_bitmap (CoglBitmap *src_bmp,
79 _cogl_bitmap_from_file (const char *filename,
83 _cogl_bitmap_unpremult (CoglBitmap *dst_bmp);
86 _cogl_bitmap_premult (CoglBitmap *dst_bmp);
89 _cogl_bitmap_convert_premult_status (CoglBitmap *bmp,
90 CoglPixelFormat dst_format);
93 _cogl_bitmap_copy_subregion (CoglBitmap *src,
102 /* Creates a deep copy of the source bitmap */
104 _cogl_bitmap_copy (CoglBitmap *src_bmp);
107 _cogl_bitmap_get_size_from_file (const char *filename,
112 _cogl_bitmap_set_format (CoglBitmap *bitmap,
113 CoglPixelFormat format);
115 /* Maps the bitmap so that the pixels can be accessed directly or if
116 the bitmap is just a memory bitmap then it just returns the pointer
117 to memory. Note that the bitmap isn't guaranteed to allocated to
118 the full size of rowstride*height so it is not safe to read up to
119 the rowstride of the last row. This will be the case if the user
120 uploads data using gdk_pixbuf_new_subpixbuf with a sub region
121 containing the last row of the pixbuf because in that case the
122 rowstride can be much larger than the width of the image */
124 _cogl_bitmap_map (CoglBitmap *bitmap,
125 CoglBufferAccess access,
126 CoglBufferMapHint hints);
129 _cogl_bitmap_unmap (CoglBitmap *bitmap);
131 /* These two are replacements for map and unmap that should used when
132 the pointer is going to be passed to GL for pixel packing or
133 unpacking. The address might not be valid for reading if the bitmap
134 was created with new_from_buffer but it will however be good to
135 pass to glTexImage2D for example. The access should be READ for
136 unpacking and WRITE for packing. It can not be both */
138 _cogl_bitmap_bind (CoglBitmap *bitmap,
139 CoglBufferAccess access,
140 CoglBufferMapHint hints);
143 _cogl_bitmap_unbind (CoglBitmap *bitmap);
145 #endif /* __COGL_BITMAP_H */