! (c)2010 Joe Groff bsd license
USING: accessors alien.data cocoa cocoa.classes cocoa.messages
combinators core-foundation.data core-graphics.types fry images
-images.loader io kernel literals math sequences ;
+images.loader io kernel math sequences ;
IN: images.cocoa
SINGLETON: ns-image
: check-return ( n -- )
{
- { $ NSImageRepLoadStatusUnknownType [ ns-image-unknown-type ] }
- { $ NSImageRepLoadStatusInvalidData [ ns-image-invalid-data ] }
- { $ NSImageRepLoadStatusUnexpectedEOF [ ns-image-unexpected-eof ] }
+ { NSImageRepLoadStatusUnknownType [ ns-image-unknown-type ] }
+ { NSImageRepLoadStatusInvalidData [ ns-image-invalid-data ] }
+ { NSImageRepLoadStatusUnexpectedEOF [ ns-image-unexpected-eof ] }
[ drop ]
} case ;
! (c)2010 Joe Groff bsd license\r
USING: accessors alien.c-types alien.data alien.enums\r
-classes.struct destructors images images.loader\r
-io.streams.limited kernel locals math windows.com\r
-windows.gdiplus windows.streams windows.types typed\r
-byte-arrays grouping sequences ;\r
+classes.struct destructors images images.loader kernel locals\r
+math windows.com windows.gdiplus windows.streams windows.types\r
+typed byte-arrays grouping sequences ;\r
IN: images.gdiplus\r
\r
SINGLETON: gdi+-image\r
! Copyright (C) 2009 Doug Coleman, Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
-USING: assocs byte-arrays io.encodings.binary io.files
-io.pathnames io.streams.byte-array io.streams.limited
-io.streams.throwing kernel namespaces sequences strings
-unicode.case fry ;
+USING: ascii assocs byte-arrays io.encodings.binary io.files
+io.pathnames io.streams.byte-array kernel namespaces sequences
+strings fry ;
IN: images.loader
ERROR: unknown-image-extension extension ;
: image-class ( path -- class )
file-extension (image-class) ;
-: open-image-file ( path -- stream )
- binary <limited-file-reader> ;
-
PRIVATE>
! Image Decode
swap types get set-at ;
: load-image ( path -- image )
- [ open-image-file ] [ image-class ] bi load-image* ;
+ [ binary <file-reader> ] [ image-class ] bi load-image* ;
M: object load-image* stream>image ;
M: byte-array load-image*
[ binary <byte-reader> ] dip stream>image ;
-M: string load-image* [ open-image-file ] dip stream>image ;
+M: string load-image*
+ [ binary <file-reader> ] dip stream>image ;
-M: pathname load-image* [ open-image-file ] dip stream>image ;
+M: pathname load-image*
+ [ binary <file-reader> ] dip stream>image ;
! Image Encode
: save-graphic-image ( image path -- )
[ image-class ] [ ] bi
binary [ image>stream ] with-file-writer ;
-