diff options
author | scuri <scuri> | 2009-09-25 18:40:30 +0000 |
---|---|---|
committer | scuri <scuri> | 2009-09-25 18:40:30 +0000 |
commit | 9f84f624d3a6be89804a55ddea878f4cdaca6e77 (patch) | |
tree | 0872bd951622453ed761f14fe7b03d76c4eda567 | |
parent | 5ba44ee397f7524ed6808a62f0bdb8ebc7f0045b (diff) |
*** empty log message ***
-rw-r--r-- | include/im_image.h | 3 | ||||
-rw-r--r-- | src/lua5/imlua_image.c | 6 | ||||
-rw-r--r-- | src/process/im_quantize.cpp | 5 |
3 files changed, 8 insertions, 6 deletions
diff --git a/include/im_image.h b/include/im_image.h index 09de54b..12dbad8 100644 --- a/include/im_image.h +++ b/include/im_image.h @@ -183,7 +183,8 @@ void imImageClear(imImage* image); int imImageIsBitmap(const imImage* image); /** Changes the image palette. - * This will destroy the existing palette and replace it with the given palette buffer. + * This will destroy the existing palette and replace it with the given palette pointer. + * Only the pointer is stored, so the palette should be a new palette and it can not be a static array. * * \verbatim image:SetPalette(palette: imPalette) [in Lua 5] \endverbatim * \ingroup imgclass */ diff --git a/src/lua5/imlua_image.c b/src/lua5/imlua_image.c index 6d5ea2b..40b1e9c 100644 --- a/src/lua5/imlua_image.c +++ b/src/lua5/imlua_image.c @@ -2,7 +2,7 @@ * \brief IM Lua 5 Binding * * See Copyright Notice in im_lib.h - * $Id: imlua_image.c,v 1.4 2009/08/19 21:33:55 scuri Exp $ + * $Id: imlua_image.c,v 1.5 2009/09/25 18:40:31 scuri Exp $ */ #include <string.h> @@ -479,7 +479,9 @@ static int imluaImageSetPalette (lua_State *L) { imImage *image = imlua_checkimage(L, 1); imluaPalette *pal = imlua_checkpalette(L, 2); - imImageSetPalette(image, pal->color, pal->count); + long* palette = (long*)malloc(sizeof(long)*256); + memcpy(palette, pal->color, pal->count*sizeof(long)); + imImageSetPalette(image, palette, pal->count); return 0; } diff --git a/src/process/im_quantize.cpp b/src/process/im_quantize.cpp index 9a65f4c..de78cf4 100644 --- a/src/process/im_quantize.cpp +++ b/src/process/im_quantize.cpp @@ -2,7 +2,7 @@ * \brief Additional Image Quantization Operations * * See Copyright Notice in im_lib.h - * $Id: im_quantize.cpp,v 1.1 2008/10/17 06:16:33 scuri Exp $ + * $Id: im_quantize.cpp,v 1.2 2009/09/25 18:40:32 scuri Exp $ */ @@ -24,8 +24,7 @@ void imProcessQuantizeRGBUniform(const imImage* src_image, imImage* dst_image, i *green_map=(imbyte*)src_image->data[1], *blue_map=(imbyte*)src_image->data[2]; - long *palette = imPaletteUniform(); - imImageSetPalette(dst_image, palette, 256); + imImageSetPalette(dst_image, imPaletteUniform(), 256); for (int y = 0; y < src_image->height; y++) { |