Re: [Flashcoders] Bitmap filters

2006-10-19 Thread David Buff
To invert your image, just create a MovieClip in your library, then put your 
picture inside, and link this MovieClip with the id: picture_id.


the code is:

import flash.filters.ColorMatrixFilter;

var matrix:Array = new Array();
matrix = matrix.concat([-1, 0, 0, 0, 256]); // red
matrix = matrix.concat([0, -1, 0, 0, 256]); // green
matrix = matrix.concat([0, 0, -1, 0, 256]); // blue
matrix = matrix.concat([0, 0, 0, 1, 0]); // alpha

var filter:ColorMatrixFilter = new ColorMatrixFilter(matrix);

_root.attachMovie(picture_id,pictureMc,1,{x:10,y:10});
pictureMc.filters = new Array(filter);

To understand:
I you take the exemple of a 100% red picture, you've red=256, green=0, 
blue=0. The invert of the red is cyan: red=0, green=256, blue=256


Then reed the oline help of colorMatrixFilter, you can see that:

redResult = a[0] * srcR + a[1] * srcG + a[2] * srcB + a[3] * srcA + a[4]

so the first line of your matrix is -1,0,0,0,256 so redResult = -1*srcR + 0 
+ 0 + 0 + 256 -- srcR = 256 and -256 + 256 = 0 the result is 0
so the second line of your matrix is 0,-1,0,0,256 so redResult = 0 + -1*srcG 
+ 0 + 0 + 256 -- srcG = 0 and 0 + 256 = 0 the result is 256

same for blue.

Your global result is red=0,green=256,blue=256 it's a invert image.

- Original Message - 
From: Keith Reinfeld [EMAIL PROTECTED]

To: 'Flashcoders mailing list' flashcoders@chattyfig.figleaf.com
Sent: Wednesday, October 18, 2006 9:54 PM
Subject: RE: [Flashcoders] Bitmap filters



Randy,

You can use ColorTransform to invert colors:

// code
stop();

import flash.geom.ColorTransform;
import flash.geom.Transform;

toggleClr_btn.label.text = Invert;
toggleClr_btn.onRelease = toggleClr;

var imgClr:Transform = new Transform(image_mc);
var toggleFlag:Boolean = false;
function toggleClr():Void{
toggleFlag = !toggleFlag;
if(toggleFlag){
// invert
var clrTrans:ColorTransform = new ColorTransform(-1, -1, -1,
1, 255, 255, 255, 0);
imgClr.colorTransform = clrTrans;
}else{
// restore
var clrTrans:ColorTransform = new ColorTransform(1, 1, 1, 1,
0, 0, 0, 0);
imgClr.colorTransform = clrTrans;
}
}

HTH

-Keith
http://home.mn.rr.com/keithreinfeld



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Randy 
Tinfow

Sent: Wednesday, October 18, 2006 12:07 PM
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] Bitmap filters

Having a hard time understanding the new bitmap filters, specifically
the color matrix filter.  We want to programmatically invert an image's
colors.  Is there any documentation that explains the color matrix
properties succintctly?  Or provides step-by-step instructions on it's
application?

Thanks,

Randy Tinfow
IMAGE PLANT
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com



___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] Bitmap filters

2006-10-18 Thread Randy Tinfow
Having a hard time understanding the new bitmap filters, specifically
the color matrix filter.  We want to programmatically invert an image's
colors.  Is there any documentation that explains the color matrix
properties succintctly?  Or provides step-by-step instructions on it's
application?

Thanks,

Randy Tinfow
IMAGE PLANT
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] Bitmap filters

2006-10-18 Thread julien castelain

hi randy,

in this article, (which is in french but i guess you could try to
translate it) 
http://www.tweenpix.net/blog/index.php?2005/09/21/532-colormatrixfilter
there's really good stuff

ciao

On 10/18/06, Randy Tinfow [EMAIL PROTECTED] wrote:

Having a hard time understanding the new bitmap filters, specifically
the color matrix filter.  We want to programmatically invert an image's
colors.  Is there any documentation that explains the color matrix
properties succintctly?  Or provides step-by-step instructions on it's
application?

Thanks,

Randy Tinfow
IMAGE PLANT
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com