コード例 #1
0
ファイル: Controller.cs プロジェクト: yzwbrian/winform-ui
        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
ファイル: Controller.cs プロジェクト: yzwbrian/winform-ui
        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);
        }
コード例 #4
0
ファイル: Controller.cs プロジェクト: yzwbrian/winform-ui
        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
        }