images: gdiplus had a resource leak (file descriptor). change stream>image to dispose of the

stream no matter what.
db4
Doug Coleman 2012-08-25 11:44:40 -07:00
parent d62fea3bbc
commit 2b9f4668b6
12 changed files with 27 additions and 26 deletions

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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
{

View File

@ -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 ;

View File

@ -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

View File

@ -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

View File

@ -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 ;

View File

@ -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

View File

@ -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

View File

@ -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