1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien.c-types alien.data destructors fry images
4 kernel libc math sequences ;
7 ! Some code shared by core-graphics and cairo for constructing
8 ! images from off-screen graphics contexts. There is probably
9 ! no reason to call it directly.
13 : bitmap-size ( dim -- n ) product "uint" heap-size * ;
15 : malloc-bitmap-data ( dim -- alien ) bitmap-size 1 calloc &free ;
17 : bitmap-data ( alien dim -- data ) bitmap-size memory>byte-array ;
19 : <bitmap-image> ( alien dim -- image )
27 : make-memory-bitmap ( dim quot -- image )
29 [ malloc-bitmap-data ] keep _ [ <bitmap-image> ] 2bi
30 ] with-destructors ; inline