Пример #1
0
        protected virtual void OnTransfromNeeded(object sender, TransfromNeededEventArg e)
        {
            try
            {
                e.ClipRectangle = clipRect;
                e.CurrentTime   = CurrentTime;

                if (TransfromNeeded != null)
                {
                    TransfromNeeded(this, e);
                }
                else
                {
                    e.UseDefaultMatrix = true;
                }

                if (e.UseDefaultMatrix)
                {
                    TransfromHelper.DoScale(e, animation);
                    TransfromHelper.DoRotate(e, animation);
                    TransfromHelper.DoSlide(e, animation);
                }
            }
            catch
            {
            }
        }
Пример #2
0
        protected virtual Bitmap OnNonLinearTransfromNeeded()
        {
            Bitmap bmp = null;

            if (CtrlBmp == null)
            {
                return(null);
            }

            try
            {
                bmp = new Bitmap(Width, Height);

                const int   bytesPerPixel = 4;
                PixelFormat pxf           = PixelFormat.Format32bppArgb;
                Rectangle   rect          = new Rectangle(0, 0, bmp.Width, bmp.Height);
                BitmapData  bmpData       = bmp.LockBits(rect, ImageLockMode.ReadWrite, pxf);
                IntPtr      ptr           = bmpData.Scan0;
                int         numBytes      = bmp.Width * bmp.Height * bytesPerPixel;
                byte[]      argbValues    = new byte[numBytes];

                Marshal.Copy(ptr, argbValues, 0, numBytes);

                var e = new NonLinearTransfromNeededEventArg()
                {
                    CurrentTime = CurrentTime, ClientRectangle = ClientRectangle, Pixels = argbValues, Stride = bmpData.Stride, SourcePixels = CtrlPixels, SourceClientRectangle = new Rectangle(Padding.Left, Padding.Top, DecoratedControl.Width, DecoratedControl.Height), SourceStride = CtrlStride
                };

                try
                {
                    if (NonLinearTransfromNeeded != null)
                    {
                        NonLinearTransfromNeeded(this, e);
                    }
                    else
                    {
                        e.UseDefaultTransform = true;
                    }

                    if (e.UseDefaultTransform)
                    {
                        switch (DecorationType)
                        {
                        case DecorationType.BottomMirror: TransfromHelper.DoBottomMirror(e); break;
                        }
                    }
                }catch {}

                Marshal.Copy(argbValues, 0, ptr, numBytes);
                bmp.UnlockBits(bmpData);
            }
            catch
            {
            }

            return(bmp);
        }
Пример #3
0
        protected virtual Bitmap OnNonLinearTransfromNeeded()
        {
            Bitmap bmp = null;

            if (ctrlBmp == null)
            {
                return(null);
            }

            try
            {
                bmp = (Bitmap)ctrlBmp.Clone();

                const int   bytesPerPixel = 4;
                PixelFormat pxf           = PixelFormat.Format32bppArgb;
                Rectangle   rect          = new Rectangle(0, 0, bmp.Width, bmp.Height);
                BitmapData  bmpData       = bmp.LockBits(rect, ImageLockMode.ReadWrite, pxf);
                IntPtr      ptr           = bmpData.Scan0;
                int         numBytes      = bmp.Width * bmp.Height * bytesPerPixel;
                byte[]      argbValues    = new byte[numBytes];

                System.Runtime.InteropServices.Marshal.Copy(ptr, argbValues, 0, numBytes);

                var e = new NonLinearTransfromNeededEventArg()
                {
                    CurrentTime = CurrentTime, ClientRectangle = DoubleBitmap.ClientRectangle, Pixels = argbValues, Stride = bmpData.Stride
                };

                if (NonLinearTransfromNeeded != null)
                {
                    NonLinearTransfromNeeded(this, e);
                }
                else
                {
                    e.UseDefaultTransform = true;
                }

                if (e.UseDefaultTransform)
                {
                    TransfromHelper.DoBlind(e, animation);
                    TransfromHelper.DoMosaic(e, animation, ref buffer, ref pixelsBuffer);

                    TransfromHelper.DoTransparent(e, animation);
                    TransfromHelper.DoLeaf(e, animation);
                }

                System.Runtime.InteropServices.Marshal.Copy(argbValues, 0, ptr, numBytes);
                bmp.UnlockBits(bmpData);
            }
            catch
            {
            }

            return(bmp);
        }
        public void EndUpdate()
        {
            Bitmap bitmap = this.GetBackground(this.AnimatedControl, true, true);

            if (this.animation.AnimateOnlyDifferences)
            {
                TransfromHelper.CalcDifference(bitmap, this.BgBmp);
            }
            this.ctrlBmp = bitmap;
            this.mode    = AnimateMode.Update;
        }
        protected virtual Bitmap OnNonLinearTransfromNeeded()
        {
            Bitmap bitmap = null;

            if (this.CtrlBmp == null)
            {
                return(null);
            }
            try
            {
                bitmap = new Bitmap(base.Width, base.Height);
                PixelFormat format      = PixelFormat.Format32bppArgb;
                Rectangle   rect        = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
                BitmapData  bitmapdata  = bitmap.LockBits(rect, ImageLockMode.ReadWrite, format);
                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 == AnimatorNS.DecorationType.BottomMirror))
                    {
                        TransfromHelper.DoBottomMirror(e);
                    }
                }
                catch
                {
                }
                Marshal.Copy(destination, 0, source, length);
                bitmap.UnlockBits(bitmapdata);
            }
            catch
            {
            }
            return(bitmap);
        }
        protected virtual Bitmap OnNonLinearTransfromNeeded()
        {
            Bitmap bitmap = null;

            if (this.ctrlBmp == null)
            {
                return(null);
            }
            try
            {
                bitmap = (Bitmap)this.ctrlBmp.Clone();
                PixelFormat format      = PixelFormat.Format32bppArgb;
                Rectangle   rect        = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
                BitmapData  bitmapdata  = bitmap.LockBits(rect, ImageLockMode.ReadWrite, format);
                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);
        }
Пример #7
0
        public void EndUpdate()
        {
            var bmp = GetBackground(AnimatedControl, true, true);

#if debug
            bmp.Save("c:\\bmp.png");
#endif
            if (animation.AnimateOnlyDifferences)
            {
                TransfromHelper.CalcDifference(bmp, BgBmp);
            }

            ctrlBmp = bmp;
            mode    = AnimateMode.Update;
#if debug
            ctrlBmp.Save("c:\\ctrlBmp.png");
#endif
        }
Пример #8
0
        protected virtual void OnTransfromNeeded(TransfromNeededEventArg e)
        {
            try
            {
                if (TransfromNeeded != null)
                {
                    TransfromNeeded(this, e);
                }
                else
                {
                    e.UseDefaultMatrix = true;
                }

                if (e.UseDefaultMatrix)
                {
                    TransfromHelper.DoScale(e, animation);
                    TransfromHelper.DoRotate(e, animation);
                    TransfromHelper.DoSlide(e, animation);
                }
            }
            catch
            {
            }
        }