public void Apply(RippleEffect effect, DrawingLayer sourceLayer, DrawingLayer targetLayer)
        {
            effect.Center = Center;
            effect.Amplitude = Amplitude;
            effect.Frequency = Frequency;
            effect.LightIntensity = LightIntensity;
            effect.Phase = Phase;

            sourceLayer.ApplyEffect(effect, targetLayer);
        }
Beispiel #2
0
        public DrawingLayer CalculateHistogram(DrawingLayer originalLayer)
        {
            DrawingLayer ping = originalLayer.Factory.CreateDrawingLayer(originalLayer.Width, originalLayer.Height);
            DrawingLayer pong = originalLayer.Factory.CreateDrawingLayer(originalLayer.Width, originalLayer.Height);

            float kernelHeight = 2;
            Rectangle rect = new Rectangle(0, 0, originalLayer.Width, (int)Math.Ceiling(originalLayer.Height / kernelHeight));

            DrawingLayer source = ping;
            DrawingLayer target = pong;
            SourceHeight = rect.Height;
            originalLayer.ApplyEffect(this, source, rect, false);

            rect.Height = (int)Math.Ceiling(rect.Height / kernelHeight);

            while (rect.Height > 1)
            {
                SourceHeight = rect.Height;
                source.ApplyEffect(this, target, rect, false);

                //Swap layers for next round
                DrawingLayer temp = source;
                source = target;
                target = temp;

                rect.Height = (int)Math.Ceiling(rect.Height / kernelHeight);
            }

            //Target was switched with source, so source points to last result
            return source;
        }