From 0ea078ad03b53d860a427dbf8cad1b7f8002dd7c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 13 Jul 2013 12:58:00 +0000 Subject: [PATCH] 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). --- source/blender/imbuf/intern/util.c | 19 ++++++++++++++----- .../windowmanager/intern/wm_playanim.c | 5 +++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 234d80bf782..4ec5879cfac 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -158,9 +158,13 @@ const char *imb_ext_audio[] = { 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; struct stat st; - int fp, buf[10]; + int fp; 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) return FALSE; - if (read(fp, buf, 32) != 32) { + memset(buf, 0, sizeof(buf)); + if (read(fp, buf, HEADER_SIZE) <= 0) { close(fp); return FALSE; } @@ -180,14 +185,18 @@ static int IMB_ispic_name(const char *name) close(fp); /* XXX move this exception */ - if ((BIG_LONG(buf[0]) & 0xfffffff0) == 0xffd8ffe0) + if ((BIG_LONG(((int *)buf)[0]) & 0xfffffff0) == 0xffd8ffe0) return JPG; - for (type = IMB_FILE_TYPES; type->is_a; type++) - if (type->is_a((uchar *)buf)) + for (type = IMB_FILE_TYPES; type->is_a; type++) { + if (type->is_a(buf)) { return type->filetype; + } + } return FALSE; + +#undef HEADER_SIZE } int IMB_ispic(const char *filename) diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index b9350ca8799..e8ab1fef8b7 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -940,6 +940,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv) } } else if (!IMB_ispic(filepath)) { + printf("%s: '%s' not an image file\n", __func__, filepath); exit(1); } @@ -949,7 +950,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv) } if (ibuf == NULL) { - printf("couldn't open %s\n", filepath); + printf("%s: '%s' couldn't open\n", __func__, filepath); 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); /* 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)); return filepath; }