Make a couple utility words in images vocabulary
parent
f20ee7a53b
commit
84942b5409
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue