Collage FX Studio
PhotoMagic Studio
Photo Card Workshop
Magic Animator

Flex ColorMatrixFilter class brightness adjusting

The ColorMatrixFilter class lets you apply a 4 x 5 matrix transformation on the RGBA color and alpha values of every pixel in the input image to produce a result with a new set of RGBA color and alpha values.  You can apply the filter to any display object (that is, objects that inherit from the DisplayObject class), such as MovieClip, SimpleButton, TextField, and Video objects, as well as to BitmapData objects. Here is the example to adjusting brightness of a picture.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml" layout="vertical"
 creationComplete="transformImage()"   verticalScrollPolicy="off" horizontalScrollPolicy="off">
 <mx:Script>
  <![CDATA[
  

    [Bindable]
    [Embed(source="images/demo.jpg")]
    private var demoImage:Class;
   

   private function transformImage():void
   {
    var matrix:Array = new Array();
    matrix = matrix.concat([1, 0, 0, 0, 30]); // red
    matrix = matrix.concat([0, 1, 0, 0, 30]); // green
    matrix = matrix.concat([0, 0, 1, 0, 30]); // blue
    matrix = matrix.concat([0, 0, 0, 1, 0]);  // alpha
    var cmf:ColorMatrixFilter = new ColorMatrixFilter(matrix);    
    var filtersArray:Array = new Array();
    filtersArray.push(cmf);    
    modifiedImage.filters = filtersArray;
          
    
   }
   
   
  ]]>
 </mx:Script>
 
 <mx:HBox width="420" height="200">
  <mx:VBox>
    <mx:Label text="Original Image"/>
    <mx:Image source="{demoImage}" width="200" height="160"/>
  </mx:VBox>
  <mx:VBox>
   <mx:Label text="Modified Image"/>
   <mx:Image id="modifiedImage" source="{demoImage}" width="200" height="160"/>
  </mx:VBox>
 </mx:HBox>
 
</mx:Application>




Comment: 0 | Read times: -
Announce commentary
Your name
Content
Validation code Code