diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-11-23 03:45:54 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-11-23 09:40:10 +0300 |
commit | bc8504cb4c93eb3aac22222f62966c13560a2bf6 (patch) | |
tree | 1e3bcf5bf5a02a9722ef049dfc506f5b4c06d72e /source/blender/imbuf | |
parent | 676d790d29ead413a9619aa94005c5248d274cb2 (diff) |
Cleanup: shadowing (blenlib, gpu, imbuf)
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r-- | source/blender/imbuf/intern/targa.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c index 7073d34e2bc..0949a431293 100644 --- a/source/blender/imbuf/intern/targa.c +++ b/source/blender/imbuf/intern/targa.c @@ -554,9 +554,10 @@ ImBuf *imb_loadtarga(const unsigned char *mem, size_t mem_size, int flags, char { TARGA tga; struct ImBuf *ibuf; - int col, count, size; - unsigned int *rect, *cmap = NULL /*, mincol = 0*/, maxcol = 0; - uchar *cp = (uchar *) &col; + int count, size; + unsigned int *rect, *cmap = NULL /*, mincol = 0*/, cmap_max = 0; + int32_t cp_data; + uchar *cp = (uchar *) &cp_data; if (checktarga(&tga, mem) == 0) { return NULL; @@ -579,10 +580,10 @@ ImBuf *imb_loadtarga(const unsigned char *mem, size_t mem_size, int flags, char if (tga.mapsize) { /* load color map */ /*mincol = tga.maporig;*/ /*UNUSED*/ - maxcol = tga.mapsize; - cmap = MEM_callocN(sizeof(unsigned int) * maxcol, "targa cmap"); + cmap_max = tga.mapsize; + cmap = MEM_callocN(sizeof(unsigned int) * cmap_max, "targa cmap"); - for (count = 0; count < maxcol; count++) { + for (count = 0; count < cmap_max; count++) { switch (tga.mapbits >> 3) { case 4: cp[0] = mem[3]; @@ -603,14 +604,16 @@ ImBuf *imb_loadtarga(const unsigned char *mem, size_t mem_size, int flags, char mem += 2; break; case 1: - col = *mem++; + cp_data = *mem++; break; } - cmap[count] = col; + cmap[count] = cp_data; } size = 0; - for (col = maxcol - 1; col > 0; col >>= 1) size++; + for (int cmap_index = cmap_max - 1; cmap_index > 0; cmap_index >>= 1) { + size++; + } ibuf->planes = size; if (tga.mapbits != 32) { /* set alpha bits */ @@ -655,14 +658,17 @@ ImBuf *imb_loadtarga(const unsigned char *mem, size_t mem_size, int flags, char /* apply color map */ rect = ibuf->rect; for (size = ibuf->x * ibuf->y; size > 0; --size, ++rect) { - col = *rect; - if (col >= 0 && col < maxcol) *rect = cmap[col]; + int cmap_index = *rect; + if (cmap_index >= 0 && cmap_index < cmap_max) { + *rect = cmap[cmap_index]; + } } MEM_freeN(cmap); } if (tga.pixsize == 16) { + unsigned int col; rect = ibuf->rect; for (size = ibuf->x * ibuf->y; size > 0; --size, ++rect) { col = *rect; |