images: gdiplus had a resource leak (file descriptor). change stream>image to dispose of the
stream no matter what.db4
parent
d62fea3bbc
commit
2b9f4668b6
|
@ -33,5 +33,5 @@ os macosx? [
|
|||
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 ;
|
||||
|
|
|
@ -57,10 +57,9 @@ os windows? [
|
|||
|
||||
PRIVATE>
|
||||
|
||||
M: gdi+-image stream>image
|
||||
drop [
|
||||
M: gdi+-image stream>image*
|
||||
drop
|
||||
start-gdi+ &stop-gdi+ drop
|
||||
stream>gdi+-bitmap
|
||||
gdi+-bitmap>data
|
||||
data>image
|
||||
] with-destructors ;
|
||||
data>image ;
|
||||
|
|
|
@ -64,9 +64,8 @@ os linux? [
|
|||
|
||||
PRIVATE>
|
||||
|
||||
M: gtk-image stream>image
|
||||
drop [
|
||||
M: gtk-image stream>image*
|
||||
drop
|
||||
stream-contents data>GInputStream &g_object_unref
|
||||
GInputStream>GdkPixbuf &g_object_unref
|
||||
GdkPixbuf>image
|
||||
] with-destructors ;
|
||||
GdkPixbuf>image ;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
! 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 ;
|
||||
|
@ -24,7 +24,10 @@ PRIVATE>
|
|||
|
||||
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 ;
|
||||
|
|
|
@ -370,7 +370,7 @@ ERROR: unsupported-bitmap-file magic ;
|
|||
: 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
|
||||
{
|
||||
|
|
|
@ -248,5 +248,5 @@ ERROR: loading-gif-error gif-image ;
|
|||
: 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 ;
|
||||
|
|
|
@ -72,7 +72,7 @@ SINGLETON: pbm-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
|
||||
|
|
|
@ -49,7 +49,7 @@ SINGLETON: pgm-image
|
|||
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
|
||||
|
|
|
@ -357,5 +357,5 @@ ERROR: invalid-color-type/bit-depth loading-png ;
|
|||
] throw-on-eof
|
||||
] with-input-stream ;
|
||||
|
||||
M: png-image stream>image
|
||||
M: png-image stream>image*
|
||||
drop load-png loading-png>image ;
|
||||
|
|
|
@ -46,7 +46,7 @@ SINGLETON: ppm-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
|
||||
|
|
|
@ -253,7 +253,7 @@ ERROR: bad-tga-unsupported ;
|
|||
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
|
||||
|
|
|
@ -560,7 +560,7 @@ ERROR: unknown-component-order ifd ;
|
|||
[ 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
|
||||
|
|
Loading…
Reference in New Issue