stream no matter what.
0 0 w h <CGRect> image CGContextDrawImage
] make-bitmap-image ;
-M: ns-image stream>image
+M: ns-image stream>image*
drop stream-contents <CGImage> CGImage>image ;
\r
PRIVATE>\r
\r
-M: gdi+-image stream>image\r
- drop [\r
- start-gdi+ &stop-gdi+ drop\r
- stream>gdi+-bitmap\r
- gdi+-bitmap>data\r
- data>image\r
- ] with-destructors ;\r
+M: gdi+-image stream>image*\r
+ drop\r
+ start-gdi+ &stop-gdi+ drop\r
+ stream>gdi+-bitmap\r
+ gdi+-bitmap>data\r
+ data>image ;\r
PRIVATE>
-M: gtk-image stream>image
- drop [
- stream-contents data>GInputStream &g_object_unref
- GInputStream>GdkPixbuf &g_object_unref
- GdkPixbuf>image
- ] with-destructors ;
+M: gtk-image stream>image*
+ drop
+ stream-contents data>GInputStream &g_object_unref
+ GInputStream>GdkPixbuf &g_object_unref
+ GdkPixbuf>image ;
! Copyright (C) 2009 Doug Coleman, Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
-USING: ascii assocs byte-arrays io.encodings.binary io.files
-io.pathnames io.streams.byte-array kernel namespaces sequences
-strings fry ;
+USING: ascii assocs byte-arrays destructors fry
+io.encodings.binary io.files io.pathnames io.streams.byte-array
+kernel namespaces sequences strings ;
IN: images.loader
ERROR: unknown-image-extension extension ;
GENERIC# load-image* 1 ( obj class -- image )
-GENERIC: stream>image ( stream class -- image )
+GENERIC: stream>image* ( stream class -- image )
+
+: stream>image ( stream class -- image )
+ '[ _ &dispose _ stream>image* ] with-destructors ; inline
: register-image-class ( extension class -- )
swap types get set-at ;
: loading-bitmap>bytes ( loading-bitmap -- byte-array )
uncompress-bitmap bitmap>bytes ;
-M: bmp-image stream>image ( stream bmp-image -- bitmap )
+M: bmp-image stream>image* ( stream bmp-image -- bitmap )
drop load-bitmap
[ image new ] dip
{
: ensure-loaded ( gif-image -- gif-image )
dup loading?>> [ loading-gif-error ] when ;
-M: gif-image stream>image ( path gif-image -- image )
+M: gif-image stream>image* ( path gif-image -- image )
drop load-gif ensure-loaded gif>image ;
ubyte-components >>component-type ;
PRIVATE>
-M: pbm-image stream>image
+M: pbm-image stream>image*
drop [ [ read-pbm ] throw-on-eof ] with-input-stream ;
M: pbm-image image>stream
data >>bitmap
wide [ ushort-components ] [ ubyte-components ] if >>component-type ;
-M: pgm-image stream>image
+M: pgm-image stream>image*
drop [ [ read-pgm ] throw-on-eof ] with-input-stream ;
M: pgm-image image>stream
] throw-on-eof
] with-input-stream ;
-M: png-image stream>image
+M: png-image stream>image*
drop load-png loading-png>image ;
data >>bitmap
ubyte-components >>component-type ;
-M: ppm-image stream>image
+M: ppm-image stream>image*
drop [ [ read-ppm ] throw-on-eof ] with-input-stream ;
M: ppm-image image>stream
image-data >>bitmap
ubyte-components >>component-type ;
-M: tga-image stream>image
+M: tga-image stream>image*
drop [ [ read-tga ] throw-on-eof ] with-input-stream ;
M: tga-image image>stream
[ process-tif-ifds ] with-tiff-endianness ;
! tiff files can store several images -- we just take the first for now
-M: tiff-image stream>image ( stream tiff-image -- image )
+M: tiff-image stream>image* ( stream tiff-image -- image )
drop [ [ load-tiff tiff>image ] throw-on-eof ] with-input-stream ;
{ "tif" "tiff" } [ tiff-image register-image-class ] each