images.loader: added image encode protocol
parent
17b52314dc
commit
f297e88987
|
@ -1,9 +1,9 @@
|
||||||
! 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: accessors assocs byte-arrays combinators images
|
USING: accessors assocs byte-arrays combinators images
|
||||||
io.encodings.binary io.pathnames io.streams.byte-array
|
io.encodings.binary io.files io.pathnames io.streams.byte-array
|
||||||
io.streams.limited kernel namespaces splitting strings
|
io.streams.limited kernel namespaces sequences splitting
|
||||||
unicode.case sequences ;
|
strings unicode.case ;
|
||||||
IN: images.loader
|
IN: images.loader
|
||||||
|
|
||||||
ERROR: unknown-image-extension extension ;
|
ERROR: unknown-image-extension extension ;
|
||||||
|
@ -22,6 +22,8 @@ types [ H{ } clone ] initialize
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
|
! Image Decode
|
||||||
|
|
||||||
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 )
|
||||||
|
@ -43,3 +45,11 @@ M: limited-stream load-image* stream>image ;
|
||||||
M: string load-image* [ open-image-file ] dip stream>image ;
|
M: string load-image* [ open-image-file ] dip stream>image ;
|
||||||
|
|
||||||
M: pathname load-image* [ open-image-file ] dip stream>image ;
|
M: pathname load-image* [ open-image-file ] dip stream>image ;
|
||||||
|
|
||||||
|
! Image Encode
|
||||||
|
|
||||||
|
GENERIC: image>stream ( image class -- )
|
||||||
|
|
||||||
|
: save-graphic-image ( image path -- )
|
||||||
|
[ image-class ] [ ] bi
|
||||||
|
binary [ image>stream ] with-file-writer ;
|
||||||
|
|
Loading…
Reference in New Issue