]> gitweb.factorcode.org Git - factor.git/commitdiff
Make a couple utility words in images vocabulary
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 20 Sep 2010 02:43:36 +0000 (21:43 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 20 Sep 2010 02:43:36 +0000 (21:43 -0500)
basis/images/images.factor

index 6cbcdb9508f7235f4294f5a3fc5e8f7ad0efe306..4cea5f9f66da8e5a6c159f66278cbfcd64358918 100644 (file)
@@ -66,6 +66,11 @@ TUPLE: image dim component-order component-type upside-down? bitmap ;
 
 : <image> ( -- image ) image new ; inline
 
+: <rgb-image> ( -- image )
+    <image>
+        RGB >>component-order
+        ubyte-components >>component-type ; inline
+
 : has-alpha? ( image -- ? ) component-order>> alpha-channel? ;
 
 : bytes-per-component ( component-type -- n )
@@ -125,6 +130,9 @@ TUPLE: image dim component-order component-type upside-down? bitmap ;
 
 : bytes-per-pixel ( image -- n )
     [ component-order>> ] [ component-type>> ] bi (bytes-per-pixel) ;
+    
+: bytes-per-image ( image -- n )
+    [ dim>> product ] [ bytes-per-pixel ] bi * ;
 
 <PRIVATE