! Copyright (C) 2009 Doug Coleman, Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors combinators kernel locals math sequences ;
+USING: accessors combinators kernel math sequences ;
IN: images
SINGLETONS:
: set-pixel-at ( pixel x y image -- )
[ 1 ] dip set-pixel-row-at ; inline
+
+:: each-pixel ( ... image quot: ( ... x y pixel -- ... ) -- ... )
+ image dim>> first2 :> ( width height )
+ image bytes-per-pixel :> n
+ height width [ <iota> ] bi@ [| y x |
+ y width * x + :> start
+ start n * :> from
+ from n + :> to
+ x y from to image bitmap>> <slice> quot call
+ ] cartesian-each ; inline