Toggle black & white to color on bitmap in Scaleform (problem)

When i use this code to toggle a bitmap to color or black & white, it works fine when running in the scaleform Gfx player in Animate, however when running in the game engine, the image simply disappears.

private function ToggleImageColor(img:Bitmap, bColor:Boolean):void
{
    if (bColor) {
        img.filters=[];
    } else {
        var red:Number = 0.2225;
        var green:Number = 0.7169;
        var blue:Number = 0.0606;

        var matrix:Array=   [red, green, blue, 0, 0,
            red, green, blue, 0, 0,
            red, green, blue, 0, 0,
            0, 0, 0, 1, 0];
        var cmf:ColorMatrixFilter = new ColorMatrixFilter();
        cmf.matrix = matrix;

        img.filters=[cmf];
    }
}

It is as soon as I apply the ColorMatrixFilter to img.filters that the image disappears.

Anyone know why? Or any other ideas of how to render a bitmap in grayscale?

1 Like

There are some bitmap functions that just don’t work in UE3’s implementation of Flash. I guess you found another one.

I think you’re going to have to desaturate the image in UnrealScript and draw it to the canvas.

Or you could make a desaturated copy of every possible texture, and in your Scaleform movie put the desaturated copy under the color copy, and make the color copy visible/invisible to toggle between them.

1 Like