[trunk] Follow up to r1691. Handle signed case.

This commit is contained in:
Mathieu Malaterre 2012-05-29 09:33:28 +00:00
parent bdb4d96678
commit b8cc257ac5
1 changed files with 11 additions and 3 deletions

View File

@ -3001,8 +3001,16 @@ 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);
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);