Skip to main content
Known Participant
July 22, 2011
Question

Why ColorMatrix doesn't work on iOS ?

  • July 22, 2011
  • 1 reply
  • 1545 views

Hi, as the Adobe Evangelist Ryan Stewart does in this video (time - 2.45) --> http://www.youtube.com/watch?v=jBL1BJrcjUY

I want to apply a Color Matrix Filter to my MovieClip/Loader containing an image.

Here is the code I used:

stage.addEventListener(MouseEvent.MOUSE_DOWN,fn_mD);

function fn_mD(e:MouseEvent):void

{

var matrix:Array = new Array();

matrix = matrix.concat([0.5,0.5,0.5,0,0]);// red

matrix = matrix.concat([0.5,0.5,0.5,0,0]);// green

matrix = matrix.concat([0.5,0.5,0.5,0,0]);// blue

matrix = matrix.concat([0,0,0,1,0]);// alpha

var my_filter:ColorMatrixFilter = new ColorMatrixFilter(matrix);

myObjectName.filters = [my_filter];

}

Making the preview by pressing ALT+F12 (Mac) or only F12 (Windows) all works perfectly... but after the publishing on iOS it doesn't work.

Can you help me???

Thanks

Brandon

This topic has been closed for replies.

1 reply

Known Participant
July 22, 2011

PS -> I did my test on an iPhone 4

Participant
August 31, 2011

I've been beating my head against this wall for a few days. I've found that no filters work when in GPU mode, unless you use the bitmapData.applyFilter command. Try setting <renderMode>cpu</renderMode> in your app XML and see how it runs. Otherwise, you must force bitmapData.applyFilter, like this:

bitmapData.applyFilter(sourceBitmapData, rect, point, new ColorMatrixFilter(colorMatrix));

Instead of:

bitmap.filters = [new ColorMatrixFilter(matrix)];

I've found that the ColorMatrixFilter is performs very poorly on iOS devices, to the point where my frame rate drops by a factor of 10 and NEVER recovers.

I'm trying to allow the user to brighten/contrast a photo they've taken on their camera. Sometimes it works, sometimes it doesn't. Very frustrating.

Participant
January 30, 2012

thanks dave

I was too having the same problem , coloratrix not working on android or ios, setting it to cpu rather then gpu did get it to work.

Did you ever manage to get it workign in GPU mode as performance takes a hit in CPU mode.

Taran