1 USING: accessors continuations glib.ffi images.loader
2 io.files.temp kernel layouts sequences system tools.test ;
3 IN: images.loader.tests
5 : open-png-image ( -- image )
6 "vocab:images/testing/png/basi0g01.png" load-image ;
8 : convert-to ( image format -- image' )
9 "foo." prepend temp-file [ save-graphic-image ] keep load-image ;
12 ! Windows can handle these three formats fine.
14 { "png" "tif" "gif" } [
15 open-png-image [ swap convert-to ] keep =
24 open-png-image [ swap convert-to ] keep =
28 ! It either can save to gif or throw a g-error if the gif encoder
31 [ open-png-image dup "gif" convert-to = ] [ g-error? ] recover
35 os { linux windows } member? [
39 "hai!" save-graphic-image
40 ] [ unknown-image-extension? ] recover
43 ! Windows 32 can't save .bmp-files for unknown reason. It can load
47 open-png-image dup "bmp" convert-to =
52 "vocab:images/testing/bmp/rgb_8bit.bmp" load-image dup
53 "foo.png" temp-file [ save-graphic-image ] [ load-image ] bi =
57 ! On Windows, this image didn't load due to a funny problem with a
58 ! callback triggering a gc causing an important pointer to be
59 ! moved. Only happened with tiff images too.
61 "vocab:gpu/demos/bunny/loading.tiff" load-image dim>>