public static void DoBottomMirror(NonLinearTransfromNeededEventArg e)
        {
            byte[] sourcePixels = e.SourcePixels;
            byte[] pixels       = e.Pixels;
            int    stride       = e.Stride;
            int    num2         = 1;
            int    num3         = e.SourceClientRectangle.Bottom + 1;
            int    height       = e.ClientRectangle.Height;
            int    left         = e.SourceClientRectangle.Left;
            int    right        = e.SourceClientRectangle.Right;
            int    num7         = height - num3;

            for (int i = left; i < right; i++)
            {
                for (int j = num3; j < height; j++)
                {
                    int num10 = ((num3 - 1) - num2) - (j - num3);
                    if (num10 < 0)
                    {
                        break;
                    }
                    int num11 = i;
                    int index = (num10 * stride) + (num11 * 4);
                    int num13 = (j * stride) + (i * 4);
                    pixels[num13]     = sourcePixels[index];
                    pixels[num13 + 1] = sourcePixels[index + 1];
                    pixels[num13 + 2] = sourcePixels[index + 2];
                    pixels[num13 + 3] = (byte)((1f - ((1f * (j - num3)) / ((float)num7))) * 90f);
                }
            }
        }
 public static void DoBlind(NonLinearTransfromNeededEventArg e, Animation animation)
 {
     if (animation.BlindCoeff != PointF.Empty)
     {
         byte[] pixels = e.Pixels;
         int width = e.ClientRectangle.Width;
         int height = e.ClientRectangle.Height;
         int stride = e.Stride;
         float x = animation.BlindCoeff.X;
         float y = animation.BlindCoeff.Y;
         int num8 = (int)(((width * x) + (height * y)) * (1f - e.CurrentTime));
         for (int i = 0; i < width; i++)
         {
             for (int j = 0; j < height; j++)
             {
                 int num5 = (j * stride) + (i * 4);
                 float num9 = ((i * x) + (j * y)) - num8;
                 if (num9 >= 0f)
                 {
                     pixels[num5 + 3] = 0;
                 }
             }
         }
     }
 }
 public static void DoBlind(NonLinearTransfromNeededEventArg e, Animation animation)
 {
     if (animation.BlindCoeff != PointF.Empty)
     {
         byte[] pixels = e.Pixels;
         int    width  = e.ClientRectangle.Width;
         int    height = e.ClientRectangle.Height;
         int    stride = e.Stride;
         float  x      = animation.BlindCoeff.X;
         float  y      = animation.BlindCoeff.Y;
         int    num8   = (int)(((width * x) + (height * y)) * (1f - e.CurrentTime));
         for (int i = 0; i < width; i++)
         {
             for (int j = 0; j < height; j++)
             {
                 int   num5 = (j * stride) + (i * 4);
                 float num9 = ((i * x) + (j * y)) - num8;
                 if (num9 >= 0f)
                 {
                     pixels[num5 + 3] = 0;
                 }
             }
         }
     }
 }
Beispiel #4
0
 protected virtual void OnNonLinearTransfromNeeded(object sender, NonLinearTransfromNeededEventArg e)
 {
     if (this.NonLinearTransfromNeeded != null)
     {
         this.NonLinearTransfromNeeded(this, e);
     }
     else
     {
         e.UseDefaultTransform = true;
     }
 }
Beispiel #5
0
        protected virtual Bitmap OnNonLinearTransfromNeeded()
        {
            Bitmap bitmap = null;

            if (this.ctrlBmp == null)
            {
                return(null);
            }
            try
            {
                bitmap = (Bitmap)this.ctrlBmp.Clone();
                Rectangle  rect        = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
                BitmapData bitmapdata  = bitmap.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
                IntPtr     source      = bitmapdata.Scan0;
                int        length      = (bitmap.Width * bitmap.Height) * 4;
                byte[]     destination = new byte[length];
                Marshal.Copy(source, destination, 0, length);
                NonLinearTransfromNeededEventArg e = new NonLinearTransfromNeededEventArg
                {
                    CurrentTime     = this.CurrentTime,
                    ClientRectangle = this.DoubleBitmap.ClientRectangle,
                    Pixels          = destination,
                    Stride          = bitmapdata.Stride
                };
                if (this.NonLinearTransfromNeeded != null)
                {
                    this.NonLinearTransfromNeeded(this, e);
                }
                else
                {
                    e.UseDefaultTransform = true;
                }
                if (e.UseDefaultTransform)
                {
                    TransfromHelper.DoBlind(e, this.animation);
                    TransfromHelper.DoMosaic(e, this.animation, ref this.buffer, ref this.pixelsBuffer);
                    TransfromHelper.DoTransparent(e, this.animation);
                    TransfromHelper.DoLeaf(e, this.animation);
                }
                Marshal.Copy(destination, 0, source, length);
                bitmap.UnlockBits(bitmapdata);
            }
            catch
            {
            }
            return(bitmap);
        }
        public static void DoBlur(NonLinearTransfromNeededEventArg e, int r)
        {
            byte[] pixels       = e.Pixels;
            byte[] sourcePixels = e.SourcePixels;
            int    stride       = e.Stride;
            int    height       = e.ClientRectangle.Height;
            int    width        = e.ClientRectangle.Width;
            int    num4         = sourcePixels.Length - 4;

            for (int i = r; i < (width - r); i++)
            {
                for (int j = r; j < (height - r); j++)
                {
                    int index = (j * stride) + (i * 4);
                    int num14 = 0;
                    int num13 = 0;
                    int num11 = 0;
                    int num15 = 0;
                    int num12 = 0;
                    for (int k = i - r; k < (i + r); k++)
                    {
                        for (int m = j - r; m < (j + r); m++)
                        {
                            int num8 = (m * stride) + (k * 4);
                            if (((num8 >= 0) && (num8 < num4)) && (sourcePixels[num8 + 3] > 0))
                            {
                                num11 += sourcePixels[num8];
                                num13 += sourcePixels[num8 + 1];
                                num14 += sourcePixels[num8 + 2];
                                num15 += sourcePixels[num8 + 3];
                                num12++;
                            }
                        }
                    }
                    if ((index < num4) && (num12 > 5))
                    {
                        pixels[index]     = (byte)(num11 / num12);
                        pixels[index + 1] = (byte)(num13 / num12);
                        pixels[index + 2] = (byte)(num14 / num12);
                        pixels[index + 3] = (byte)(num15 / num12);
                    }
                }
            }
        }
 public static void DoBlur(NonLinearTransfromNeededEventArg e, int r)
 {
     byte[] pixels = e.Pixels;
     byte[] sourcePixels = e.SourcePixels;
     int stride = e.Stride;
     int height = e.ClientRectangle.Height;
     int width = e.ClientRectangle.Width;
     int num4 = sourcePixels.Length - 4;
     for (int i = r; i < (width - r); i++)
     {
         for (int j = r; j < (height - r); j++)
         {
             int index = (j * stride) + (i * 4);
             int num14 = 0;
             int num13 = 0;
             int num11 = 0;
             int num15 = 0;
             int num12 = 0;
             for (int k = i - r; k < (i + r); k++)
             {
                 for (int m = j - r; m < (j + r); m++)
                 {
                     int num8 = (m * stride) + (k * 4);
                     if (((num8 >= 0) && (num8 < num4)) && (sourcePixels[num8 + 3] > 0))
                     {
                         num11 += sourcePixels[num8];
                         num13 += sourcePixels[num8 + 1];
                         num14 += sourcePixels[num8 + 2];
                         num15 += sourcePixels[num8 + 3];
                         num12++;
                     }
                 }
             }
             if ((index < num4) && (num12 > 5))
             {
                 pixels[index] = (byte)(num11 / num12);
                 pixels[index + 1] = (byte)(num13 / num12);
                 pixels[index + 2] = (byte)(num14 / num12);
                 pixels[index + 3] = (byte)(num15 / num12);
             }
         }
     }
 }
 public static void DoTransparent(NonLinearTransfromNeededEventArg e, Animation animation)
 {
     if (animation.TransparencyCoeff != 0f)
     {
         float num2 = 1f - (animation.TransparencyCoeff * e.CurrentTime);
         if (num2 < 0f)
         {
             num2 = 0f;
         }
         if (num2 > 1f)
         {
             num2 = 1f;
         }
         byte[] pixels = e.Pixels;
         for (int i = 0; i < pixels.Length; i += 4)
         {
             pixels[i + 3] = (byte)(pixels[i + 3] * num2);
         }
     }
 }
 public static void DoLeaf(NonLinearTransfromNeededEventArg e, Animation animation)
 {
     if (animation.LeafCoeff != 0f)
     {
         byte[] pixels = e.Pixels;
         int    width  = e.ClientRectangle.Width;
         int    height = e.ClientRectangle.Height;
         int    stride = e.Stride;
         int    num7   = (int)((width + height) * (1f - (e.CurrentTime * e.CurrentTime)));
         int    length = pixels.Length;
         for (int i = 0; i < width; i++)
         {
             for (int j = 0; j < height; j++)
             {
                 int index = (j * stride) + (i * 4);
                 if ((i + j) >= num7)
                 {
                     int num9 = num7 - j;
                     int num8 = num7 - i;
                     int num2 = (num7 - i) - j;
                     if (num2 < -20)
                     {
                         num2 = -20;
                     }
                     int num = (num8 * stride) + (num9 * 4);
                     if ((((num9 >= 0) && (num8 >= 0)) && ((num >= 0) && (num < length))) && (pixels[index + 3] > 0))
                     {
                         pixels[num]     = (byte)Math.Min(0xff, (num2 + 250) + (pixels[index] / 10));
                         pixels[num + 1] = (byte)Math.Min(0xff, (num2 + 250) + (pixels[index + 1] / 10));
                         pixels[num + 2] = (byte)Math.Min(0xff, (num2 + 250) + (pixels[index + 2] / 10));
                         pixels[num + 3] = 230;
                     }
                     pixels[index + 3] = 0;
                 }
             }
         }
     }
 }
 protected virtual Bitmap OnNonLinearTransfromNeeded()
 {
     Bitmap bitmap = null;
     if (this.CtrlBmp == null)
     {
         return null;
     }
     try
     {
         bitmap = new Bitmap(base.Width, base.Height);
         Rectangle rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
         BitmapData bitmapdata = bitmap.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
         IntPtr source = bitmapdata.Scan0;
         int length = (bitmap.Width * bitmap.Height) * 4;
         byte[] destination = new byte[length];
         Marshal.Copy(source, destination, 0, length);
         NonLinearTransfromNeededEventArg e = new NonLinearTransfromNeededEventArg
         {
             CurrentTime = this.CurrentTime,
             ClientRectangle = base.ClientRectangle,
             Pixels = destination,
             Stride = bitmapdata.Stride,
             SourcePixels = this.CtrlPixels,
             SourceClientRectangle = new Rectangle(this.Padding.Left, this.Padding.Top, this.DecoratedControl.Width, this.DecoratedControl.Height),
             SourceStride = this.CtrlStride
         };
         try
         {
             if (this.NonLinearTransfromNeeded != null)
             {
                 this.NonLinearTransfromNeeded(this, e);
             }
             else
             {
                 e.UseDefaultTransform = true;
             }
             if (e.UseDefaultTransform && (this.DecorationType == DecorationType.BottomMirror))
             {
                 TransfromHelper.DoBottomMirror(e);
             }
         }
         catch
         {
         }
         Marshal.Copy(destination, 0, source, length);
         bitmap.UnlockBits(bitmapdata);
     }
     catch
     {
     }
     return bitmap;
 }
Beispiel #11
0
 protected virtual void OnNonLinearTransfromNeeded(object sender, NonLinearTransfromNeededEventArg e)
 {
     if (this.NonLinearTransfromNeeded != null)
     {
         this.NonLinearTransfromNeeded(this, e);
     }
     else
     {
         e.UseDefaultTransform = true;
     }
 }
 public static void DoTransparent(NonLinearTransfromNeededEventArg e, Animation animation)
 {
     if (animation.TransparencyCoeff != 0f)
     {
         float num2 = 1f - (animation.TransparencyCoeff * e.CurrentTime);
         if (num2 < 0f)
         {
             num2 = 0f;
         }
         if (num2 > 1f)
         {
             num2 = 1f;
         }
         byte[] pixels = e.Pixels;
         for (int i = 0; i < pixels.Length; i += 4)
         {
             pixels[i + 3] = (byte)(pixels[i + 3] * num2);
         }
     }
 }
 public static void DoMosaic(NonLinearTransfromNeededEventArg e, Animation animation, ref Point[] buffer, ref byte[] pixelsBuffer)
 {
     if ((animation.MosaicCoeff != PointF.Empty) && (animation.MosaicSize != 0))
     {
         byte[] pixels = e.Pixels;
         int width = e.ClientRectangle.Width;
         int height = e.ClientRectangle.Height;
         int stride = e.Stride;
         float currentTime = e.CurrentTime;
         int length = pixels.Length;
         float num7 = 1f - e.CurrentTime;
         if (num7 < 0f)
         {
             num7 = 0f;
         }
         if (num7 > 1f)
         {
             num7 = 1f;
         }
         float x = animation.MosaicCoeff.X;
         float y = animation.MosaicCoeff.Y;
         if (buffer == null)
         {
             buffer = new Point[pixels.Length];
             for (int k = 0; k < pixels.Length; k++)
             {
                 buffer[k] = new Point((int)(x * (rnd.NextDouble() - 0.5)), (int)(y * (rnd.NextDouble() - 0.5)));
             }
         }
         if (pixelsBuffer == null)
         {
             pixelsBuffer = (byte[])pixels.Clone();
         }
         for (int i = 0; i < length; i += 4)
         {
             pixels[i] = 0xff;
             pixels[i + 1] = 0xff;
             pixels[i + 2] = 0xff;
             pixels[i + 3] = 0;
         }
         int mosaicSize = animation.MosaicSize;
         float num16 = animation.MosaicShift.X;
         float num17 = animation.MosaicShift.Y;
         for (int j = 0; j < height; j++)
         {
             for (int m = 0; m < width; m++)
             {
                 int num12 = j / mosaicSize;
                 int num13 = m / mosaicSize;
                 int index = (j * stride) + (m * 4);
                 int num14 = (num12 * stride) + (num13 * 4);
                 int num = m + ((int)(currentTime * (buffer[num14].X + (num13 * num16))));
                 int num3 = j + ((int)(currentTime * (buffer[num14].Y + (num12 * num17))));
                 if (((num >= 0) && (num < width)) && ((num3 >= 0) && (num3 < height)))
                 {
                     int num5 = (num3 * stride) + (num * 4);
                     pixels[num5] = pixelsBuffer[index];
                     pixels[num5 + 1] = pixelsBuffer[index + 1];
                     pixels[num5 + 2] = pixelsBuffer[index + 2];
                     pixels[num5 + 3] = (byte)(pixelsBuffer[index + 3] * num7);
                 }
             }
         }
     }
 }
 public static void DoLeaf(NonLinearTransfromNeededEventArg e, Animation animation)
 {
     if (animation.LeafCoeff != 0f)
     {
         byte[] pixels = e.Pixels;
         int width = e.ClientRectangle.Width;
         int height = e.ClientRectangle.Height;
         int stride = e.Stride;
         int num7 = (int)((width + height) * (1f - (e.CurrentTime * e.CurrentTime)));
         int length = pixels.Length;
         for (int i = 0; i < width; i++)
         {
             for (int j = 0; j < height; j++)
             {
                 int index = (j * stride) + (i * 4);
                 if ((i + j) >= num7)
                 {
                     int num9 = num7 - j;
                     int num8 = num7 - i;
                     int num2 = (num7 - i) - j;
                     if (num2 < -20)
                     {
                         num2 = -20;
                     }
                     int num = (num8 * stride) + (num9 * 4);
                     if ((((num9 >= 0) && (num8 >= 0)) && ((num >= 0) && (num < length))) && (pixels[index + 3] > 0))
                     {
                         pixels[num] = (byte)Math.Min(0xff, (num2 + 250) + (pixels[index] / 10));
                         pixels[num + 1] = (byte)Math.Min(0xff, (num2 + 250) + (pixels[index + 1] / 10));
                         pixels[num + 2] = (byte)Math.Min(0xff, (num2 + 250) + (pixels[index + 2] / 10));
                         pixels[num + 3] = 230;
                     }
                     pixels[index + 3] = 0;
                 }
             }
         }
     }
 }
 public static void DoBottomMirror(NonLinearTransfromNeededEventArg e)
 {
     byte[] sourcePixels = e.SourcePixels;
     byte[] pixels = e.Pixels;
     int stride = e.Stride;
     int num2 = 1;
     int num3 = e.SourceClientRectangle.Bottom + 1;
     int height = e.ClientRectangle.Height;
     int left = e.SourceClientRectangle.Left;
     int right = e.SourceClientRectangle.Right;
     int num7 = height - num3;
     for (int i = left; i < right; i++)
     {
         for (int j = num3; j < height; j++)
         {
             int num10 = ((num3 - 1) - num2) - (j - num3);
             if (num10 < 0)
             {
                 break;
             }
             int num11 = i;
             int index = (num10 * stride) + (num11 * 4);
             int num13 = (j * stride) + (i * 4);
             pixels[num13] = sourcePixels[index];
             pixels[num13 + 1] = sourcePixels[index + 1];
             pixels[num13 + 2] = sourcePixels[index + 2];
             pixels[num13 + 3] = (byte)((1f - ((1f * (j - num3)) / ((float)num7))) * 90f);
         }
     }
 }
 protected virtual Bitmap OnNonLinearTransfromNeeded()
 {
     Bitmap bitmap = null;
     if (this.ctrlBmp == null)
     {
         return null;
     }
     try
     {
         bitmap = (Bitmap)this.ctrlBmp.Clone();
         Rectangle rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
         BitmapData bitmapdata = bitmap.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
         IntPtr source = bitmapdata.Scan0;
         int length = (bitmap.Width * bitmap.Height) * 4;
         byte[] destination = new byte[length];
         Marshal.Copy(source, destination, 0, length);
         NonLinearTransfromNeededEventArg e = new NonLinearTransfromNeededEventArg
         {
             CurrentTime = this.CurrentTime,
             ClientRectangle = this.DoubleBitmap.ClientRectangle,
             Pixels = destination,
             Stride = bitmapdata.Stride
         };
         if (this.NonLinearTransfromNeeded != null)
         {
             this.NonLinearTransfromNeeded(this, e);
         }
         else
         {
             e.UseDefaultTransform = true;
         }
         if (e.UseDefaultTransform)
         {
             TransfromHelper.DoBlind(e, this.animation);
             TransfromHelper.DoMosaic(e, this.animation, ref this.buffer, ref this.pixelsBuffer);
             TransfromHelper.DoTransparent(e, this.animation);
             TransfromHelper.DoLeaf(e, this.animation);
         }
         Marshal.Copy(destination, 0, source, length);
         bitmap.UnlockBits(bitmapdata);
     }
     catch
     {
     }
     return bitmap;
 }
 public static void DoMosaic(NonLinearTransfromNeededEventArg e, Animation animation, ref Point[] buffer, ref byte[] pixelsBuffer)
 {
     if ((animation.MosaicCoeff != PointF.Empty) && (animation.MosaicSize != 0))
     {
         byte[] pixels      = e.Pixels;
         int    width       = e.ClientRectangle.Width;
         int    height      = e.ClientRectangle.Height;
         int    stride      = e.Stride;
         float  currentTime = e.CurrentTime;
         int    length      = pixels.Length;
         float  num7        = 1f - e.CurrentTime;
         if (num7 < 0f)
         {
             num7 = 0f;
         }
         if (num7 > 1f)
         {
             num7 = 1f;
         }
         float x = animation.MosaicCoeff.X;
         float y = animation.MosaicCoeff.Y;
         if (buffer == null)
         {
             buffer = new Point[pixels.Length];
             for (int k = 0; k < pixels.Length; k++)
             {
                 buffer[k] = new Point((int)(x * (rnd.NextDouble() - 0.5)), (int)(y * (rnd.NextDouble() - 0.5)));
             }
         }
         if (pixelsBuffer == null)
         {
             pixelsBuffer = (byte[])pixels.Clone();
         }
         for (int i = 0; i < length; i += 4)
         {
             pixels[i]     = 0xff;
             pixels[i + 1] = 0xff;
             pixels[i + 2] = 0xff;
             pixels[i + 3] = 0;
         }
         int   mosaicSize = animation.MosaicSize;
         float num16      = animation.MosaicShift.X;
         float num17      = animation.MosaicShift.Y;
         for (int j = 0; j < height; j++)
         {
             for (int m = 0; m < width; m++)
             {
                 int num12 = j / mosaicSize;
                 int num13 = m / mosaicSize;
                 int index = (j * stride) + (m * 4);
                 int num14 = (num12 * stride) + (num13 * 4);
                 int num   = m + ((int)(currentTime * (buffer[num14].X + (num13 * num16))));
                 int num3  = j + ((int)(currentTime * (buffer[num14].Y + (num12 * num17))));
                 if (((num >= 0) && (num < width)) && ((num3 >= 0) && (num3 < height)))
                 {
                     int num5 = (num3 * stride) + (num * 4);
                     pixels[num5]     = pixelsBuffer[index];
                     pixels[num5 + 1] = pixelsBuffer[index + 1];
                     pixels[num5 + 2] = pixelsBuffer[index + 2];
                     pixels[num5 + 3] = (byte)(pixelsBuffer[index + 3] * num7);
                 }
             }
         }
     }
 }