Paste: useful image words?
Author: | ceninan |
Mode: | factor |
Date: | Thu, 24 Jun 2010 19:33:08 |
Plain Text |
USING: byte-arrays combinator images kernel locals
sequences ;
IN: images
:: crop ( image loc dim -- image' )
loc first2 :> ( x y )
dim first2 :> ( w h )
y h y + [a,b) [ x swap w image pixel-row-slice-at ] map
[ >byte-array ] map concat
image clone
swap >>bitmap
dim >>dim ;
USING: cairo cairo.ffi combinators destructors images
images.normalization kernel ;
IN: cairo
: write-png ( image filename -- )
[
[
clone BGRA reorder-components
[ bitmap>> ] [ dim>> ] bi
<image-surface> &cairo_surface_destroy
] dip
cairo_surface_write_to_png
dup CAIRO_STATUS_SUCCESS = not [ throw ] [ drop ] if
] with-destructors ;
Author: | ceninan |
Mode: | factor |
Date: | Thu, 24 Jun 2010 19:42:36 |
Plain Text |
USING: byte-arrays combinator images kernel locals
sequences ;
IN: images
:: crop ( image loc dim -- image' )
loc first2 :> ( x y )
dim first2 :> ( w h )
y h y + [a,b) [ x swap w image pixel-row-slice-at ] map
[ >byte-array ] map concat
image clone
swap >>bitmap
dim >>dim ;
USING: cairo cairo.ffi combinators destructors images
images.normalization kernel ;
IN: cairo
: write-png ( image filename -- )
[
[
clone BGRA reorder-components
[ bitmap>> ] [ dim>> ] bi
<image-surface> &cairo_surface_destroy
] dip
cairo_surface_write_to_png (check-cairo)
] with-destructors ;
New Annotation