Flex3学习轨迹:将彩色照片转换成黑白照片

来源:互联网 发布:.win域名万网下架 编辑:程序博客网 时间:2024/06/11 19:52

通常情况下,彩色图片转换成黑白图片需要使用一定的算法来实现。在这里就使用滤镜类来实现转换。

<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" fontSize="12" >    <mx:Script>        <![CDATA[            private var rLum:Number = 0.2225;            private var gLum:Number = 0.7169;            private var bLum:Number = 0.0606;                    [Bindable]            private var bwMatrix:Array = [rLum, gLum, bLum, 0, 0,                            rLum, gLum, bLum, 0, 0,                            rLum, gLum, bLum, 0, 0,                            0, 0, 0, 1, 0];                        [Bindable]            [Embed('assets/image.jpg')]            private var image1:Class;        ]]>    </mx:Script>    <mx:ColorMatrixFilter id="cmf" matrix="{bwMatrix}" />        <mx:Panel title="实现将彩色图片转换为黑白色" width="360" height="240"         verticalAlign="middle" horizontalAlign="center">        <mx:HBox>            <mx:VBox>                <mx:Label text="原始图片" />                <mx:Image source="{image1}" />            </mx:VBox>            <mx:VBox>                <mx:Label text="黑白图片" />                <mx:Image source="{image1}" filters="{[cmf]}" />            </mx:VBox>       </mx:HBox>    </mx:Panel></mx:Application>


原创粉丝点击