1 ! Copyright (C) 2009 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel accessors grouping sequences combinators ;
6 SINGLETONS: BGR RGB BGRA RGBA ABGR ARGB RGBX XRGB BGRX XBGR ;
8 TUPLE: image dim component-order byte-order bitmap ;
10 : <image> ( -- image ) image new ; inline
12 GENERIC: load-image* ( path tuple -- image )
14 : normalize-component-order ( image -- image )
20 4 <sliced-groups> dup [ [ 0 3 ] dip <slice> reverse-here ] each
24 [ 3 <sliced-groups> [ 255 suffix ] map concat ] change-bitmap
28 3 <sliced-groups> dup [ [ 0 3 ] dip <slice> reverse-here ] each
29 [ 255 suffix ] map concat
33 RGBA >>component-order ;
35 GENERIC: normalize-scan-line-order ( image -- image )
37 M: image normalize-scan-line-order ;
39 : normalize-image ( image -- image )
40 normalize-component-order
41 normalize-scan-line-order ;