From 77a4608ee1f828ed70ec58588f0229cd57758148 Mon Sep 17 00:00:00 2001 From: scuri Date: Tue, 18 Aug 2009 02:21:01 +0000 Subject: *** empty log message *** --- src/im_convertbitmap.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src/im_convertbitmap.cpp') diff --git a/src/im_convertbitmap.cpp b/src/im_convertbitmap.cpp index 9d3c720..a4f6b70 100644 --- a/src/im_convertbitmap.cpp +++ b/src/im_convertbitmap.cpp @@ -2,7 +2,7 @@ * \brief Image Conversion * * See Copyright Notice in im_lib.h - * $Id: im_convertbitmap.cpp,v 1.2 2009/08/13 22:34:25 scuri Exp $ + * $Id: im_convertbitmap.cpp,v 1.3 2009/08/18 02:23:33 scuri Exp $ */ #include "im.h" @@ -129,7 +129,7 @@ static void iImageMakeGray(imbyte *map, int count, int step) } } -static void iImageCopyMapAlpha(imbyte *map, imbyte *gldata, int depth, int count) +static void iImageGLCopyMapAlpha(imbyte *map, imbyte *gldata, int depth, int count) { /* gldata can be GL_RGBA or GL_LUMINANCE_ALPHA */ gldata += depth-1; /* position at first alpha */ @@ -141,38 +141,38 @@ static void iImageCopyMapAlpha(imbyte *map, imbyte *gldata, int depth, int count } } -static void iImageSetTranspMap(imbyte *map, imbyte *gldata, int count, imbyte *transp_map, int transp_count) +static void iImageGLSetTranspColor(imbyte *gldata, int count, imbyte r, imbyte g, imbyte b) { /* gldata is GL_RGBA */ - gldata += 3; /* position at first alpha */ for(int i = 0; i < count; i++) { - if (*map < transp_count) - *gldata = transp_map[*map]; + if (*(gldata+0) == r && + *(gldata+1) == g && + *(gldata+2) == b) + *(gldata+3) = 0; /* transparent */ else - *gldata = 255; /* opaque */ - - map++; + *(gldata+3) = 255; /* opaque */ gldata += 4; } } -static void iImageSetTranspColor(imbyte *gldata, int count, imbyte r, imbyte g, imbyte b) +static void iImageGLSetTranspMap(imbyte *map, imbyte *gldata, int count, imbyte *transp_map, int transp_count) { /* gldata is GL_RGBA */ + gldata += 3; /* position at first alpha */ for(int i = 0; i < count; i++) { - if (*(gldata+0) == r && - *(gldata+1) == g && - *(gldata+2) == b) - *(gldata+3) = 0; /* transparent */ + if (*map < transp_count) + *gldata = transp_map[*map]; else - *(gldata+3) = 255; /* opaque */ + *gldata = 255; /* opaque */ + + map++; gldata += 4; } } -static void iImageSetTranspIndex(imbyte *map, imbyte *gldata, int depth, int count, imbyte index) +static void iImageGLSetTranspIndex(imbyte *map, imbyte *gldata, int depth, int count, imbyte index) { /* gldata can be GL_RGBA or GL_LUMINANCE_ALPHA */ gldata += depth-1; /* position at first alpha */ @@ -258,7 +258,7 @@ void* imImageGetOpenGLData(const imImage* image, int *format) imConvertPacking(image->data[0], gldata, image->width, image->height, 3, IM_BYTE, 0); if (transp_color) - iImageSetTranspColor(gldata, image->count, *(transp_color+0), *(transp_color+1), *(transp_color+2)); + iImageGLSetTranspColor(gldata, image->count, *(transp_color+0), *(transp_color+1), *(transp_color+2)); } } else @@ -271,11 +271,11 @@ void* imImageGetOpenGLData(const imImage* image, int *format) iImageMakeGray(gldata, image->count, (glformat==GL_LUMINANCE_ALPHA)? 2: 1); if (image->has_alpha) - iImageCopyMapAlpha((imbyte*)image->data[1], gldata, depth, image->count); + iImageGLCopyMapAlpha((imbyte*)image->data[1], gldata, depth, image->count); else if (transp_map) - iImageSetTranspMap((imbyte*)image->data[0], gldata, image->count, transp_map, transp_count); + iImageGLSetTranspMap((imbyte*)image->data[0], gldata, image->count, transp_map, transp_count); else if (transp_index) - iImageSetTranspIndex((imbyte*)image->data[0], gldata, depth, image->count, *transp_index); + iImageGLSetTranspIndex((imbyte*)image->data[0], gldata, depth, image->count, *transp_index); } if (format) *format = glformat; -- cgit v1.2.3