Add bytes-per-pixel word to images vocab

db4
Slava Pestov 2009-02-19 04:08:32 -06:00
parent b9de229b23
commit bdb790010a
1 changed files with 19 additions and 1 deletions

View File

@ -9,6 +9,24 @@ IN: images
SINGLETONS: BGR RGB BGRA RGBA ABGR ARGB RGBX XRGB BGRX XBGR
R16G16B16 R32G32B32 R16G16B16A16 R32G32B32A32 ;
: bytes-per-pixel ( component-order -- n )
{
{ BGR [ 3 ] }
{ RGB [ 3 ] }
{ BGRA [ 4 ] }
{ RGBA [ 4 ] }
{ ABGR [ 4 ] }
{ ARGB [ 4 ] }
{ RGBX [ 4 ] }
{ XRGB [ 4 ] }
{ BGRX [ 4 ] }
{ XBGR [ 4 ] }
{ R16G16B16 [ 6 ] }
{ R32G32B32 [ 12 ] }
{ R16G16B16A16 [ 8 ] }
{ R32G32B32A32 [ 16 ] }
} case ;
TUPLE: image dim component-order bitmap ;
: <image> ( -- image ) image new ; inline
@ -63,4 +81,4 @@ M: image normalize-scan-line-order ;
: normalize-image ( image -- image )
[ >byte-array ] change-bitmap
normalize-component-order
normalize-scan-line-order ;
normalize-scan-line-order ;