diff options
author | Kent Mein <mein@cs.umn.edu> | 2006-02-28 21:30:16 +0300 |
---|---|---|
committer | Kent Mein <mein@cs.umn.edu> | 2006-02-28 21:30:16 +0300 |
commit | 59aced7a509e40654eec4e321f60ce20f173450d (patch) | |
tree | 1ba917b7e0a5e61c85f32df5450ba7b7528d6a9d /source/blender/imbuf/intern/jpeg.c | |
parent | 21df108cb92355c60f6b4852ac7a558b5ffa778e (diff) |
Fix for bug #3886
Basically the check for a type of jpeg was messed up.
I added a imb_is_a_jpeg function since I was working on that bit and
it makes it a little more similar to the other filetypes.
I also changed a switch statement that had the same loop for all
cases, just moved the loop outside of the switch statement.
Kent
Diffstat (limited to 'source/blender/imbuf/intern/jpeg.c')
-rw-r--r-- | source/blender/imbuf/intern/jpeg.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index afd1038a80f..906e69f0a28 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -72,6 +72,12 @@ static int jpeg_failed = FALSE; static int jpeg_default_quality; static int ibuf_ftype; +int imb_is_a_jpeg(unsigned char *mem) { + + if ((mem[0]== 0xFF) && (mem[1] == 0xD8))return 1; + return 0; +} + static void jpeg_error (j_common_ptr cinfo) { /* Always display the message */ @@ -280,25 +286,21 @@ static ImBuf * ibJpegImageFromCinfo(struct jpeg_decompress_struct * cinfo, int f } buffer = row_pointer[0]; - switch(depth) { - case 1: - for (x = ibuf->x; x > 0; x--) { + for (x=ibuf->x; x >0; x--) { + switch(depth) { + case 1: rect[3] = 255; rect[0] = rect[1] = rect[2] = *buffer++; rect += 4; - } - break; - case 3: - for (x = ibuf->x; x > 0; x--) { + break; + case 3: rect[3] = 255; rect[0] = *buffer++; rect[1] = *buffer++; rect[2] = *buffer++; rect += 4; - } - break; - case 4: - for (x = ibuf->x; x > 0; x--) { + break; + case 4: r = *buffer++; g = *buffer++; b = *buffer++; @@ -326,7 +328,7 @@ static ImBuf * ibJpegImageFromCinfo(struct jpeg_decompress_struct * cinfo, int f rect[1] = g; rect[0] = r; rect += 4; - } + } } } jpeg_finish_decompress(cinfo); |