天天看點

将圖檔轉換為黑白圖檔的例子

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" backgroundColor="white"> 

    <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/image2.jpg')]

            private var image2:Class; 

        ]]>

    </mx:Script> 

    <mx:ColorMatrixFilter id="cmf" matrix="{bwMatrix}" /> 

    <mx:VBox>

        <mx:Label text="Black and white" />

        <mx:Image source="{image2}" filters="{[cmf]}" scaleX="0.5" scaleY="0.5" />

    </mx:VBox> 

    <mx:VBox>

        <mx:Label text="Original" />

        <mx:Image source="{image2}" scaleX="0.5" scaleY="0.5" />

    </mx:VBox>     

</mx:Application>

繼續閱讀