diff options
| author | Mickael Savinaud <savmickael@users.noreply.github.com> | 2011-10-19 15:45:03 +0000 |
|---|---|---|
| committer | Mickael Savinaud <savmickael@users.noreply.github.com> | 2011-10-19 15:45:03 +0000 |
| commit | 1dc6eddf1cc8b091d6eba01e33d76f04cde2211a (patch) | |
| tree | d23fc5baba49376689d815152d17fe92438f3297 /applications/codec | |
| parent | c1510793e39dc26ae55f243905ae562764d94842 (diff) | |
backport rev 1013-1014 from trunk
Diffstat (limited to 'applications/codec')
| -rw-r--r-- | applications/codec/convert.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/applications/codec/convert.c b/applications/codec/convert.c index fae8b131..4efd1f1d 100644 --- a/applications/codec/convert.c +++ b/applications/codec/convert.c @@ -389,7 +389,7 @@ opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) { int imagetotga(opj_image_t * image, const char *outfile) { int width, height, bpp, x, y; opj_bool write_alpha; - int i; + int i, adjustR, adjustG, adjustB; unsigned int alpha_channel; float r,g,b,a; unsigned char value; @@ -426,15 +426,19 @@ int imagetotga(opj_image_t * image, const char *outfile) { scale = 255.0f / (float)((1<<image->comps[0].prec)-1); + adjustR = (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0); + adjustG = (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0); + adjustB = (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0); + for (y=0; y < height; y++) { unsigned int index=y*width; for (x=0; x < width; x++, index++) { - r = (float)(image->comps[0].data[index]); + r = (float)(image->comps[0].data[index] + adjustR); if (image->numcomps>2) { - g = (float)(image->comps[1].data[index]); - b = (float)(image->comps[2].data[index]); + g = (float)(image->comps[1].data[index] + adjustG); + b = (float)(image->comps[2].data[index] + adjustB); } else {// Greyscale ... g = r; |
