예제 #1
0
        BaseFilter IFilterVisitor <ISwfStreamReader, BaseFilter> .Visit(ConvolutionFilter filter, ISwfStreamReader reader)
        {
            var matrixX = reader.ReadByte();
            var matrixY = reader.ReadByte();

            filter.Divisor = reader.ReadSingle();
            filter.Bias    = reader.ReadSingle();
            filter.Matrix  = new double[matrixY, matrixX];
            for (var x = 0; x < matrixX; x++)
            {
                for (var y = 0; y < matrixY; y++)
                {
                    filter.Matrix[y, x] = reader.ReadSingle();
                }
            }
            filter.DefaultColor  = reader.ReadRGBA();
            filter.Reserved      = (byte)reader.ReadUnsignedBits(6);
            filter.Clamp         = reader.ReadBit();
            filter.PreserveAlpha = reader.ReadBit();
            return(filter);
        }
예제 #2
0
        object IFilterVisitor <ISwfStreamWriter, object> .Visit(ConvolutionFilter filter, ISwfStreamWriter writer)
        {
            writer.WriteByte((byte)filter.MatrixX);
            writer.WriteByte((byte)filter.MatrixY);

            writer.WriteSingle((float)filter.Divisor);
            writer.WriteSingle((float)filter.Bias);

            for (var x = 0; x < filter.MatrixX; x++)
            {
                for (var y = 0; y < filter.MatrixY; y++)
                {
                    writer.WriteSingle((float)filter.Matrix[y, x]);
                }
            }

            writer.WriteRGBA(filter.DefaultColor);
            writer.WriteUnsignedBits(filter.Reserved, 6);
            writer.WriteBit(filter.Clamp);
            writer.WriteBit(filter.PreserveAlpha);
            return(null);
        }