AtlatestRepositorysigil-studio
sigil-studio / tree / testtest-image.sgl
1
;;; test-image.sgl - Test image loading2
;;;3
;;; This test verifies that (sigil graphics image) can load images.5
(import (sigil core)6
(sigil graphics image))8
(display "Testing image loading...\n")10
;; Test with a simple PNG file if one exists11
(define test-image-path "test/test-image.png")13
;; First test that image? returns false for non-images14
(display "Testing image? on non-image: ")15
(if (image? "not an image")16
(display "FAIL - string reported as image\n")17
(display "PASS\n"))19
(display "Testing image? on #f: ")20
(if (image? #f)21
(display "FAIL - #f reported as image\n")22
(display "PASS\n"))24
;; Try loading a test image25
(display "Attempting to load test image: ")26
(display test-image-path)27
(display "\n")29
(define img (load-image test-image-path))31
(if img32
(begin33
(display "Image loaded successfully!\n")34
(display " Width: ")35
(display (image-width img))36
(display "\n Height: ")37
(display (image-height img))38
(display "\n Channels: ")39
(display (image-channels img))40
(display "\n")42
;; Test image?43
(display "Testing image?: ")44
(if (image? img)45
(display "PASS\n")46
(display "FAIL\n"))48
;; Free the image49
(display "Freeing image...\n")50
(image-free! img)51
(display "Done.\n"))52
(begin53
(display "No test image found at ")54
(display test-image-path)55
(display "\n")56
(display "Image loading functions are available but need a test image.\n")57
(display "Create test/test-image.png to test image loading.\n")))59
(display "\nImage module test complete.\n")61
;; Return success62
0