Lomadee, uma nova espécie na web. A maior plataforma de afiliados da América Latina



Luiz Henrique de Angeli

luizdeangeli@gmail.com


Convertendo imagem para preto em branco

quinta-feira, 30 de julho de 2009



Abaixo o exemplo de como realizar a alteração das cores de uma imagem:

<?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>



Fonte : http://blog.flexexamples.com/2007/07/27/converting-an-image-to-black-and-white-using-the-colormatrixfilter/

0 comentários:


Submarino.com.br
Submarino.com.br