summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@member.fsf.org>2013-08-24 15:32:35 -0400
committerDavid Thompson <dthompson@member.fsf.org>2013-08-24 15:33:29 -0400
commitbf314ba7017c4cb0a902726a049c7313b5e1f156 (patch)
treea749ff541592bf8e8246dd0eb09702afc03669bf
parentb80e5144ebfe49f412d68002766efb01a8bc0b8a (diff)
Throw error if image file does not exist.
-rw-r--r--2d/texture.scm8
1 files changed, 7 insertions, 1 deletions
diff --git a/2d/texture.scm b/2d/texture.scm
index b7808b3..19c26c8 100644
--- a/2d/texture.scm
+++ b/2d/texture.scm
@@ -132,7 +132,13 @@
0 0 1 1)))
(define (load-bitmap filename)
- (let* ((bitmap (freeimage-load (freeimage-get-file-type filename) filename))
+ ;; Throw an error if image file does not exist or else we will
+ ;; segfault later.
+ (unless (file-exists? filename)
+ (throw 'image-not-found filename))
+ ;; Load image and convert it to 32 bit color.
+ (let* ((image-type (freeimage-get-file-type filename))
+ (bitmap (freeimage-load image-type filename))
(32bit-bitmap (freeimage-convert-to-32-bits bitmap)))
(freeimage-unload bitmap)
32bit-bitmap))