Esempio n. 1
0
 public static void CreateControlRegion(Control control, Bitmap bitmap, int Alpha)
 {
     if (control == null || bitmap == null)
     {
         return;
     }
     control.Width  = bitmap.Width;
     control.Height = bitmap.Height;
     if (control is Form)
     {
         Form form = (Form)control;
         form.Width           = control.Width;
         form.Height          = control.Height;
         form.FormBorderStyle = FormBorderStyle.None;
         form.BackgroundImage = (Image)bitmap;
         GraphicsPath path = SkinTools.CalculateControlGraphicsPath(bitmap, Alpha);
         form.Region = new Region(path);
     }
     else if (control is SkinButton)
     {
         control.Region = new Region(SkinTools.CalculateControlGraphicsPath(bitmap, Alpha));
     }
     else
     {
         if (!(control is SkinProgressBar))
         {
             return;
         }
         control.Region = new Region(SkinTools.CalculateControlGraphicsPath(bitmap, Alpha));
     }
 }
Esempio n. 2
0
 public static void CreateRegion(Control control, Rectangle bounds)
 {
     SkinTools.CreateRegion(control, bounds, 8, RoundStyle.All);
 }
Esempio n. 3
0
        public static Bitmap GaryImg(Bitmap b)
        {
            Bitmap bitmap = b.Clone(new Rectangle(0, 0, b.Width, b.Height), PixelFormat.Format24bppRgb);

            b.Dispose();
            BitmapData bitmapdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadWrite, bitmap.PixelFormat);

            byte[] numArray = new byte[bitmap.Height * bitmapdata.Stride];
            Marshal.Copy(bitmapdata.Scan0, numArray, 0, numArray.Length);
            int num1 = 0;

            for (int width = bitmap.Width; num1 < width; ++num1)
            {
                int num2 = 0;
                for (int height = bitmap.Height; num2 < height; ++num2)
                {
                    numArray[num2 * bitmapdata.Stride + num1 * 3] = numArray[num2 * bitmapdata.Stride + num1 * 3 + 1] = numArray[num2 * bitmapdata.Stride + num1 * 3 + 2] = SkinTools.GetAvg(numArray[num2 * bitmapdata.Stride + num1 * 3], numArray[num2 * bitmapdata.Stride + num1 * 3 + 1], numArray[num2 * bitmapdata.Stride + num1 * 3 + 2]);
                }
            }
            Marshal.Copy(numArray, 0, bitmapdata.Scan0, numArray.Length);
            bitmap.UnlockBits(bitmapdata);
            return(bitmap);
        }