diff options
| author | Mathieu Malaterre <mathieu.malaterre@gmail.com> | 2012-05-29 09:33:28 +0000 |
|---|---|---|
| committer | Mathieu Malaterre <mathieu.malaterre@gmail.com> | 2012-05-29 09:33:28 +0000 |
| commit | b8cc257ac52ecf92ecdbf24d5b45524e7511e4ce (patch) | |
| tree | 2a60b1172ccc4368f935e7d5fcc459c1f9fbb6d1 | |
| parent | bdb4d966782f1328f3a3f1a839a6f5d9c39c22a7 (diff) | |
[trunk] Follow up to r1691. Handle signed case.
| -rw-r--r-- | applications/codec/convert.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/applications/codec/convert.c b/applications/codec/convert.c index 19518dd0..dee780d4 100644 --- a/applications/codec/convert.c +++ b/applications/codec/convert.c @@ -3001,9 +3001,17 @@ int imagetoraw_common(opj_image_t * image, const char *outfile, opj_bool big_end unsigned char temp1; unsigned char temp2; curr = (signed short int) (*ptr & mask); - temp1 = (unsigned char) (curr >> 8); - temp2 = (unsigned char) curr; - res = fwrite(&temp1, 1, 1, rawFile); + if( big_endian ) + { + temp1 = (unsigned char) (curr >> 8); + temp2 = (unsigned char) curr; + } + else + { + temp2 = (unsigned char) (curr >> 8); + temp1 = (unsigned char) curr; + } + res = fwrite(&temp1, 1, 1, rawFile); if( res < 1 ) { fprintf(stderr, "failed to write 1 byte for %s\n", outfile); return 1; |
