From 380fdb5d8c80d094e5a8bc82bfc091bc87e6c43e Mon Sep 17 00:00:00 2001 From: scuri Date: Thu, 13 Aug 2009 22:34:25 +0000 Subject: *** empty log message *** --- src/im_file.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src/im_file.cpp') diff --git a/src/im_file.cpp b/src/im_file.cpp index a43b0d4..81e0e1b 100644 --- a/src/im_file.cpp +++ b/src/im_file.cpp @@ -2,7 +2,7 @@ * \brief File Access * * See Copyright Notice in im_lib.h - * $Id: im_file.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ + * $Id: im_file.cpp,v 1.3 2009/08/13 22:34:25 scuri Exp $ */ #include @@ -176,13 +176,28 @@ void imFileGetInfo(imFile* ifile, char* format, char* compression, int *image_co static int iFileCheckPaletteGray(imFile* ifile) { + int i; imbyte r, g, b; - for (int i = 0; i < ifile->palette_count; i++) + imbyte remaped[256]; + memset(remaped, 0, 256); + + for (i = 0; i < ifile->palette_count; i++) { imColorDecode(&r, &g, &b, ifile->palette[i]); - if (i != r || r != g || g != b) + /* if there are colors abort */ + if (r != g || g != b) return 0; + + /* grays out of order, will be remapped, but must be unique, + if there are duplicates maybe they are used for different pourposes */ + if (i != r) + { + if (!remaped[r]) + remaped[r] = 1; + else + return 0; + } } return 1; @@ -305,6 +320,16 @@ static void iFileCheckConvertGray(imFile* ifile, imbyte* data) *data = remap[*data]; data++; } + + int transp_count; + imbyte* transp_map = (imbyte*)imFileGetAttribute(ifile, "TransparencyMap", NULL, &transp_count); + if (transp_map) + { + imbyte new_transp_map[256]; + for (i=0; i