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
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
struct ImBuf;
|
||||
struct jpeg_compress_struct;
|
||||
|
||||
int imb_is_a_jpeg(unsigned char *mem);
|
||||
int imb_savejpeg(struct ImBuf * ibuf, char * name, int flags);
|
||||
struct ImBuf * imb_ibJpegImageFromFilename (char * filename, int flags);
|
||||
struct ImBuf * imb_ibJpegImageFromMemory (unsigned char * buffer, int size, int flags);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -96,7 +96,7 @@ ImBuf *IMB_ibImageFromMemory(int *mem, int size, int flags) {
|
||||
} else {
|
||||
if ((GS(mem) == IMAGIC) || (GSS(mem) == IMAGIC)){
|
||||
return (imb_loadiris((uchar *) mem, flags));
|
||||
} else if ((BIG_LONG(mem[0]) & 0xfffffff0) == 0xffd8ffe0) {
|
||||
} else if (imb_is_a_jpeg((uchar *)mem)) {
|
||||
return (imb_ibJpegImageFromMemory((uchar *)mem, size, flags));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user