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
|
0 0 w h <CGRect> image CGContextDrawImage
|
||||||
] make-bitmap-image ;
|
] make-bitmap-image ;
|
||||||
|
|
||||||
M: ns-image stream>image
|
M: ns-image stream>image*
|
||||||
drop stream-contents <CGImage> CGImage>image ;
|
drop stream-contents <CGImage> CGImage>image ;
|
||||||
|
|
|
@ -57,10 +57,9 @@ os windows? [
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
M: gdi+-image stream>image
|
M: gdi+-image stream>image*
|
||||||
drop [
|
drop
|
||||||
start-gdi+ &stop-gdi+ drop
|
start-gdi+ &stop-gdi+ drop
|
||||||
stream>gdi+-bitmap
|
stream>gdi+-bitmap
|
||||||
gdi+-bitmap>data
|
gdi+-bitmap>data
|
||||||
data>image
|
data>image ;
|
||||||
] with-destructors ;
|
|
||||||
|
|
|
@ -64,9 +64,8 @@ os linux? [
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
M: gtk-image stream>image
|
M: gtk-image stream>image*
|
||||||
drop [
|
drop
|
||||||
stream-contents data>GInputStream &g_object_unref
|
stream-contents data>GInputStream &g_object_unref
|
||||||
GInputStream>GdkPixbuf &g_object_unref
|
GInputStream>GdkPixbuf &g_object_unref
|
||||||
GdkPixbuf>image
|
GdkPixbuf>image ;
|
||||||
] with-destructors ;
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
! Copyright (C) 2009 Doug Coleman, Daniel Ehrenberg.
|
! Copyright (C) 2009 Doug Coleman, Daniel Ehrenberg.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: ascii assocs byte-arrays io.encodings.binary io.files
|
USING: ascii assocs byte-arrays destructors fry
|
||||||
io.pathnames io.streams.byte-array kernel namespaces sequences
|
io.encodings.binary io.files io.pathnames io.streams.byte-array
|
||||||
strings fry ;
|
kernel namespaces sequences strings ;
|
||||||
IN: images.loader
|
IN: images.loader
|
||||||
|
|
||||||
ERROR: unknown-image-extension extension ;
|
ERROR: unknown-image-extension extension ;
|
||||||
|
@ -24,7 +24,10 @@ PRIVATE>
|
||||||
|
|
||||||
GENERIC# load-image* 1 ( obj class -- image )
|
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 -- )
|
: register-image-class ( extension class -- )
|
||||||
swap types get set-at ;
|
swap types get set-at ;
|
||||||
|
|
|
@ -370,7 +370,7 @@ ERROR: unsupported-bitmap-file magic ;
|
||||||
: loading-bitmap>bytes ( loading-bitmap -- byte-array )
|
: loading-bitmap>bytes ( loading-bitmap -- byte-array )
|
||||||
uncompress-bitmap bitmap>bytes ;
|
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
|
drop load-bitmap
|
||||||
[ image new ] dip
|
[ image new ] dip
|
||||||
{
|
{
|
||||||
|
|
|
@ -248,5 +248,5 @@ ERROR: loading-gif-error gif-image ;
|
||||||
: ensure-loaded ( gif-image -- gif-image )
|
: ensure-loaded ( gif-image -- gif-image )
|
||||||
dup loading?>> [ loading-gif-error ] when ;
|
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 ;
|
drop load-gif ensure-loaded gif>image ;
|
||||||
|
|
|
@ -72,7 +72,7 @@ SINGLETON: pbm-image
|
||||||
ubyte-components >>component-type ;
|
ubyte-components >>component-type ;
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
M: pbm-image stream>image
|
M: pbm-image stream>image*
|
||||||
drop [ [ read-pbm ] throw-on-eof ] with-input-stream ;
|
drop [ [ read-pbm ] throw-on-eof ] with-input-stream ;
|
||||||
|
|
||||||
M: pbm-image image>stream
|
M: pbm-image image>stream
|
||||||
|
|
|
@ -49,7 +49,7 @@ SINGLETON: pgm-image
|
||||||
data >>bitmap
|
data >>bitmap
|
||||||
wide [ ushort-components ] [ ubyte-components ] if >>component-type ;
|
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 ;
|
drop [ [ read-pgm ] throw-on-eof ] with-input-stream ;
|
||||||
|
|
||||||
M: pgm-image image>stream
|
M: pgm-image image>stream
|
||||||
|
|
|
@ -357,5 +357,5 @@ ERROR: invalid-color-type/bit-depth loading-png ;
|
||||||
] throw-on-eof
|
] throw-on-eof
|
||||||
] with-input-stream ;
|
] with-input-stream ;
|
||||||
|
|
||||||
M: png-image stream>image
|
M: png-image stream>image*
|
||||||
drop load-png loading-png>image ;
|
drop load-png loading-png>image ;
|
||||||
|
|
|
@ -46,7 +46,7 @@ SINGLETON: ppm-image
|
||||||
data >>bitmap
|
data >>bitmap
|
||||||
ubyte-components >>component-type ;
|
ubyte-components >>component-type ;
|
||||||
|
|
||||||
M: ppm-image stream>image
|
M: ppm-image stream>image*
|
||||||
drop [ [ read-ppm ] throw-on-eof ] with-input-stream ;
|
drop [ [ read-ppm ] throw-on-eof ] with-input-stream ;
|
||||||
|
|
||||||
M: ppm-image image>stream
|
M: ppm-image image>stream
|
||||||
|
|
|
@ -253,7 +253,7 @@ ERROR: bad-tga-unsupported ;
|
||||||
image-data >>bitmap
|
image-data >>bitmap
|
||||||
ubyte-components >>component-type ;
|
ubyte-components >>component-type ;
|
||||||
|
|
||||||
M: tga-image stream>image
|
M: tga-image stream>image*
|
||||||
drop [ [ read-tga ] throw-on-eof ] with-input-stream ;
|
drop [ [ read-tga ] throw-on-eof ] with-input-stream ;
|
||||||
|
|
||||||
M: tga-image image>stream
|
M: tga-image image>stream
|
||||||
|
|
|
@ -560,7 +560,7 @@ ERROR: unknown-component-order ifd ;
|
||||||
[ process-tif-ifds ] with-tiff-endianness ;
|
[ process-tif-ifds ] with-tiff-endianness ;
|
||||||
|
|
||||||
! tiff files can store several images -- we just take the first for now
|
! 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 ;
|
drop [ [ load-tiff tiff>image ] throw-on-eof ] with-input-stream ;
|
||||||
|
|
||||||
{ "tif" "tiff" } [ tiff-image register-image-class ] each
|
{ "tif" "tiff" } [ tiff-image register-image-class ] each
|
||||||
|
|
Loading…
Reference in New Issue