diff options
-rw-r--r-- | html/en/history.html | 5 | ||||
-rw-r--r-- | include/im_image.h | 7 | ||||
-rw-r--r-- | src/im_image.cpp | 13 |
3 files changed, 16 insertions, 9 deletions
diff --git a/html/en/history.html b/html/en/history.html index d8c60a3..4814980 100644 --- a/html/en/history.html +++ b/html/en/history.html @@ -26,11 +26,14 @@ <h2>History of Changes</h2> <h3 dir="ltr"> - CVS (04/Apr/2011)</h3> + CVS (16/Ago/2011)</h3> <ul dir="ltr"> <li dir="ltr"><span class="hist_new">New:</span><span style="color: #008000"><span style="color: #000000"> function <strong>imImageMergeAttributes.</strong></span></span></li> + <li dir="ltr"> + <span class="hist_changed">Changed:</span> <strong>imImageInit</strong> + now accepts also the IM_ALPHA flag.</li> <li dir="ltr"><span style="color: #008000"> <span style="color: #000000"> diff --git a/include/im_image.h b/include/im_image.h index bd13c24..9d22b54 100644 --- a/include/im_image.h +++ b/include/im_image.h @@ -79,9 +79,12 @@ typedef struct _imImage imImage* imImageCreate(int width, int height, int color_space, int data_type); /** Initializes the image structure but does not allocates image data. - * See also \ref imDataType and \ref imColorSpace. + * See also \ref imDataType and \ref imColorSpace. + * The only addtional flag thar color_mode can has here is IM_ALPHA. + * To release the image structure without releasing the buffer, + * set "data[0]" to NULL before calling imImageDestroy. * \ingroup imgclass */ -imImage* imImageInit(int width, int height, int color_space, int data_type, void* data_buffer, long* palette, int palette_count); +imImage* imImageInit(int width, int height, int color_mode, int data_type, void* data_buffer, long* palette, int palette_count); /** Creates a new image based on an existing one. \n * If the addicional parameters are -1, the given image parameters are used. \n diff --git a/src/im_image.cpp b/src/im_image.cpp index 712de7f..4f8b58e 100644 --- a/src/im_image.cpp +++ b/src/im_image.cpp @@ -2,7 +2,7 @@ * \brief Image Manipulation * * See Copyright Notice in im_lib.h - * $Id: im_image.cpp,v 1.8 2011/04/04 20:42:47 scuri Exp $ + * $Id: im_image.cpp,v 1.9 2011/08/16 18:22:12 scuri Exp $ */ #include <stdlib.h> @@ -87,23 +87,24 @@ static void iImageInit(imImage* image, int width, int height, int color_space, i image->data = (void**)malloc(depth * sizeof(void*)); } -imImage* imImageInit(int width, int height, int color_space, int data_type, void* data_buffer, long* palette, int palette_count) +imImage* imImageInit(int width, int height, int color_mode, int data_type, void* data_buffer, long* palette, int palette_count) { - if (!imImageCheckFormat(color_space, data_type)) + if (!imImageCheckFormat(color_mode, data_type)) return NULL; imImage* image = (imImage*)malloc(sizeof(imImage)); image->data = 0; - iImageInit(image, width, height, color_space, data_type, 0); + iImageInit(image, width, height, imColorModeSpace(color_mode), data_type, imColorModeHasAlpha(color_mode)); if (data_buffer) { - for (int d = 0; d < image->depth; d++) + int depth = image->has_alpha? image->depth+1: image->depth; + for (int d = 0; d < depth; d++) image->data[d] = (imbyte*)data_buffer + d*image->plane_size; } - if (imColorModeDepth(color_space) == 1) + if (imColorModeDepth(imColorModeSpace(color_mode)) == 1) { image->palette = palette; image->palette_count = palette_count; |