diff options
author | scuri <scuri> | 2011-08-16 18:22:11 +0000 |
---|---|---|
committer | scuri <scuri> | 2011-08-16 18:22:11 +0000 |
commit | a2596ae54440d4d64f6df207298ab5c61513f1fa (patch) | |
tree | 1d9a2d4e77a9b842855bcf795bd09a6d79bd9122 /src/im_image.cpp | |
parent | 50118ed48c60c67ff51cf12030420bc73275a47f (diff) |
Changed: imImageInit now accepts also the IM_ALPHA flag.
Diffstat (limited to 'src/im_image.cpp')
-rw-r--r-- | src/im_image.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
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; |