Beispiel #1
0
        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="ctrlBmp"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        public void BuildReflectedImage(Bitmap ctrlBmp, NuGenReflectStyle reflectStyle, int opacity)
        {
            if (ctrlBmp == null)
            {
                throw new ArgumentNullException("ctrlBmp");
            }

            NuGenReflectedImageGenerator.RotateBitmap(ctrlBmp, reflectStyle);
            BitmapData ctrlBmpData = ctrlBmp.LockBits(
                new Rectangle(0, 0, ctrlBmp.Width, ctrlBmp.Height),
                ImageLockMode.ReadWrite,
                _pixelFormat
                );

            unsafe
            {
                uint *scan0       = (uint *)ctrlBmpData.Scan0;
                int   scanWidth   = ctrlBmpData.Stride;
                Size  ctrlBmpSize = ctrlBmp.Size;

                switch (reflectStyle)
                {
                case NuGenReflectStyle.Left:
                case NuGenReflectStyle.Right:
                {
                    for (int y = 0; y < ctrlBmpData.Height; y++)
                    {
                        for (int x = 0; x < ctrlBmpData.Width; x++)
                        {
                            uint currentOpacity = NuGenReflectedImageGenerator.GetCurrentOpacity(ctrlBmpSize, x, reflectStyle, opacity);
                            NuGenReflectedImageGenerator.ApplyOpacity(scan0, scanWidth, x, y, currentOpacity);
                        }
                    }

                    break;
                }

                default:
                {
                    for (int y = 0; y < ctrlBmpData.Height; y++)
                    {
                        uint currentOpacity = NuGenReflectedImageGenerator.GetCurrentOpacity(ctrlBmpSize, y, reflectStyle, opacity);

                        for (int x = 0; x < ctrlBmpData.Width; x++)
                        {
                            NuGenReflectedImageGenerator.ApplyOpacity(scan0, scanWidth, x, y, currentOpacity);
                        }
                    }

                    break;
                }
                }
            }

            ctrlBmp.UnlockBits(ctrlBmpData);
        }
Beispiel #2
0
        /*
         * GetCurrentOpacity
         */

        private static uint GetCurrentOpacity(Size bmpSize, int iteration, NuGenReflectStyle reflectStyle, int maxOpacity)
        {
            return((uint)Math.Min(
                       255,
                       Math.Max(
                           0,
                           Math.Round(NuGenReflectedImageGenerator.GetRawOpacity(bmpSize, iteration, reflectStyle, maxOpacity))
                           )
                       ));
        }
Beispiel #3
0
        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="ctrl"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        public Bitmap GetControlImage(Control ctrl)
        {
            if (ctrl == null)
            {
                throw new ArgumentNullException("ctrl");
            }

            Rectangle rect    = NuGenReflectedImageGenerator.GetImageRectangle(ctrl);
            Bitmap    ctrlBmp = new Bitmap(rect.Width, rect.Height, _pixelFormat);

            ctrl.DrawToBitmap(ctrlBmp, rect);
            return(ctrlBmp);
        }