Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Mein <mein@cs.umn.edu>2006-11-07 20:32:29 +0300
committerKent Mein <mein@cs.umn.edu>2006-11-07 20:32:29 +0300
commit387f3b6a07acbd64fd6b0314babbd5b8b6ff01e2 (patch)
tree8e89e213c73f687870e9d21a4fc632eda6a3c37d /source/blender/imbuf/intern/targa.c
parentf3a754136507001f27860513af76811318c4cc94 (diff)
Patch provided by (lynx3d) Mathias Wein,
It fixes endian issues with 16bit targa images. this is fixing bug #4982 Kent
Diffstat (limited to 'source/blender/imbuf/intern/targa.c')
-rw-r--r--source/blender/imbuf/intern/targa.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c
index 331c1031599..a9e83a22a8c 100644
--- a/source/blender/imbuf/intern/targa.c
+++ b/source/blender/imbuf/intern/targa.c
@@ -408,7 +408,8 @@ static void decodetarga(struct ImBuf *ibuf, unsigned char *mem, int psize)
}
} else{
if (psize & 1){
- col = (mem[0] << 8) + mem[1];
+ cp[0] = mem[0];
+ cp[1] = mem[1];
mem += 2;
} else{
col = *mem++;
@@ -445,7 +446,8 @@ static void decodetarga(struct ImBuf *ibuf, unsigned char *mem, int psize)
}
} else{
if (psize & 1){
- col = (mem[0] << 8) + mem[1];
+ cp[0] = mem[0];
+ cp[1] = mem[1];
mem += 2;
} else{
col = *mem++;
@@ -496,7 +498,8 @@ static void ldtarga(struct ImBuf * ibuf,unsigned char * mem, int psize)
}
} else{
if (psize & 1){
- col = (mem[1] << 8) + mem[0];
+ cp[0] = mem[0];
+ cp[1] = mem[1];
mem += 2;
} else{
col = *mem++;
@@ -599,11 +602,16 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, int flags)
if (tga.pixsize == 16 && ibuf->cmap == 0){
rect = ibuf->rect;
- for (size = ibuf->x * ibuf->y; size > 0; size --){
+ for (size = ibuf->x * ibuf->y; size > 0; --size, ++rect){
col = *rect;
- col = ((col & 0x1f) << 19) + ((col & 0x3e0) << 6) + ((col & 0x7c00) >> 7) ;
- col += (col & 0xe0e0e0) >> 5;
- *rect++ = col + 0xff000000;
+ uchar *cp = (uchar*)rect, *mem = (uchar*)&col;
+ cp[3] = ((mem[1] << 1) & 0xf8);
+ cp[2] = ((mem[0] & 0xe0) >> 2) + ((mem[1] & 0x03) << 6);
+ cp[1] = ((mem[0] << 3) & 0xf8);
+ cp[1] += cp[1] >> 5;
+ cp[2] += cp[2] >> 5;
+ cp[3] += cp[3] >> 5;
+ cp[0] = 0xff;
}
ibuf->depth = 24;
}