[trunk] WIP: solve problem with writing of tga image from an image with signd=1 (credit to Winfried)
This commit is contained in:
parent
5b93ae8628
commit
47d93279ff
1
CHANGES
1
CHANGES
|
@ -6,6 +6,7 @@ What's New for OpenJPEG
|
||||||
+ : added
|
+ : added
|
||||||
|
|
||||||
October 19, 2011
|
October 19, 2011
|
||||||
|
* [mickael] WIP: solve problem with writing of tga image from an image with signd=1 (credit to Winfried)
|
||||||
* [mickael] WIP: resolve some memory leak in compare functions
|
* [mickael] WIP: resolve some memory leak in compare functions
|
||||||
|
|
||||||
October 12, 2011
|
October 12, 2011
|
||||||
|
|
|
@ -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 imagetotga(opj_image_t * image, const char *outfile) {
|
||||||
int width, height, bpp, x, y;
|
int width, height, bpp, x, y;
|
||||||
opj_bool write_alpha;
|
opj_bool write_alpha;
|
||||||
int i;
|
int i, adjustR, adjustG, adjustB;
|
||||||
unsigned int alpha_channel;
|
unsigned int alpha_channel;
|
||||||
float r,g,b,a;
|
float r,g,b,a;
|
||||||
unsigned char value;
|
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);
|
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++) {
|
for (y=0; y < height; y++) {
|
||||||
unsigned int index=y*width;
|
unsigned int index=y*width;
|
||||||
|
|
||||||
for (x=0; x < width; x++, index++) {
|
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) {
|
if (image->numcomps>2) {
|
||||||
g = (float)(image->comps[1].data[index]);
|
g = (float)(image->comps[1].data[index] + adjustG);
|
||||||
b = (float)(image->comps[2].data[index]);
|
b = (float)(image->comps[2].data[index] + adjustB);
|
||||||
}
|
}
|
||||||
else {// Greyscale ...
|
else {// Greyscale ...
|
||||||
g = r;
|
g = r;
|
||||||
|
|
Loading…
Reference in New Issue