Make a couple utility words in images vocabulary

db4
Doug Coleman 2010-09-19 21:43:36 -05:00
parent f20ee7a53b
commit 84942b5409
1 changed files with 8 additions and 0 deletions

View 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