fix for 2 bugs in animation playback

- reading bmp images was failing (needed to increase the size of the header to 64 bytes)
- the dnd image was being incorrectly checked (was always returning true even when none was used).
This commit is contained in:
Campbell Barton 2013-07-13 12:58:00 +00:00
parent fe76c4ec8e
commit 0ea078ad03
2 changed files with 17 additions and 7 deletions

@ -158,9 +158,13 @@ const char *imb_ext_audio[] = {
static int IMB_ispic_name(const char *name) static int IMB_ispic_name(const char *name)
{ {
/* increased from 32 to 64 because of the bitmaps header size */
#define HEADER_SIZE 64
unsigned char buf[HEADER_SIZE];
ImFileType *type; ImFileType *type;
struct stat st; struct stat st;
int fp, buf[10]; int fp;
if (UTIL_DEBUG) printf("IMB_ispic_name: loading %s\n", name); if (UTIL_DEBUG) printf("IMB_ispic_name: loading %s\n", name);
@ -172,7 +176,8 @@ static int IMB_ispic_name(const char *name)
if ((fp = BLI_open(name, O_BINARY | O_RDONLY, 0)) < 0) if ((fp = BLI_open(name, O_BINARY | O_RDONLY, 0)) < 0)
return FALSE; return FALSE;
if (read(fp, buf, 32) != 32) { memset(buf, 0, sizeof(buf));
if (read(fp, buf, HEADER_SIZE) <= 0) {
close(fp); close(fp);
return FALSE; return FALSE;
} }
@ -180,14 +185,18 @@ static int IMB_ispic_name(const char *name)
close(fp); close(fp);
/* XXX move this exception */ /* XXX move this exception */
if ((BIG_LONG(buf[0]) & 0xfffffff0) == 0xffd8ffe0) if ((BIG_LONG(((int *)buf)[0]) & 0xfffffff0) == 0xffd8ffe0)
return JPG; return JPG;
for (type = IMB_FILE_TYPES; type->is_a; type++) for (type = IMB_FILE_TYPES; type->is_a; type++) {
if (type->is_a((uchar *)buf)) if (type->is_a(buf)) {
return type->filetype; return type->filetype;
}
}
return FALSE; return FALSE;
#undef HEADER_SIZE
} }
int IMB_ispic(const char *filename) int IMB_ispic(const char *filename)

@ -940,6 +940,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
} }
} }
else if (!IMB_ispic(filepath)) { else if (!IMB_ispic(filepath)) {
printf("%s: '%s' not an image file\n", __func__, filepath);
exit(1); exit(1);
} }
@ -949,7 +950,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
} }
if (ibuf == NULL) { if (ibuf == NULL) {
printf("couldn't open %s\n", filepath); printf("%s: '%s' couldn't open\n", __func__, filepath);
exit(1); exit(1);
} }
@ -1190,7 +1191,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
GHOST_DisposeWindow(g_WS.ghost_system, g_WS.ghost_window); GHOST_DisposeWindow(g_WS.ghost_system, g_WS.ghost_window);
/* early exit, IMB and BKE should be exited only in end */ /* early exit, IMB and BKE should be exited only in end */
if (ps.dropped_file) { if (ps.dropped_file[0]) {
BLI_strncpy(filepath, ps.dropped_file, sizeof(filepath)); BLI_strncpy(filepath, ps.dropped_file, sizeof(filepath));
return filepath; return filepath;
} }