Created
October 6, 2009 20:37
-
-
Save klazuka/203379 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: RGB>RGB ( bitmap -- bitmap' ) ; | |
: RGB>BGR ( bitmap -- bitmap' ) BGR>RGB ; inline | |
: RGB>RGBA ( bitmap -- bitmap' ) add-dummy-alpha ; inline | |
: RGB>BGRA ( bitmap -- bitmap' ) | |
3 <sliced-groups> [ <reversed> add-dummy-alpha ] map concat ; inline | |
: RGB>ARGB ( bitmap -- bitmap' ) | |
3 <sliced-groups> [ 255 prefix ] map concat ; inline | |
: RGBA>RGBA ( bitmap -- bitmap' ) ; | |
: RGBA>BGR ( bitmap -- bitmap' ) BGRA>RGB ; inline | |
: RGBA>BGRA ( bitmap -- bitmap' ) BGRA>RGBA ; inline | |
: RGBA>RGB ( bitmap -- bitmap' ) BGRA>BGR ; inline | |
: RGBA>ARGB ( bitmap -- bitmap' ) | |
4 <sliced-groups> [ unclip-last-slice prefix ] map concat ; inline | |
: ARGB>ARGB ( bitmap -- bitmap' ) ; | |
: ARGB>RGB ( bitmap -- bitmap' ) | |
4 <sliced-groups> [ rest-slice ] map concat ; inline | |
: ARGB>RGBA ( bitmap -- bitmap' ) | |
4 <sliced-groups> [ unclip-slice suffix ] map concat ; inline | |
: ARGB>BGR ( bitmap -- bitmap' ) | |
4 <sliced-groups> [ rest-slice <reversed> ] map concat ; inline | |
: ARGB>BGRA ( bitmap -- bitmap' ) | |
4 <sliced-groups> | |
[ unclip-slice [ <reversed> ] dip suffix ] map concat ; inline | |
: (reorder-colors) ( image src-order des-order -- image ) | |
[ name>> ] bi@ ">" glue "images.normalization.private" lookup | |
[ '[ _ execute( image -- image' ) ] change-bitmap ] | |
[ "No component-order conversion found." throw ] | |
if* ; | |
PRIVATE> | |
: reorder-colors ( image component-order -- image ) | |
[ | |
[ component-type>> ubyte-components assert= ] | |
[ dup component-order>> ] bi | |
] dip (reorder-colors) ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment