public static Image DrawReflection(Image img, Color toBG)
{
int height = img.Height + 100;
Bitmap bmp = new Bitmap(img.Width, height, PixelFormat.Format64bppPArgb);
Brush brsh = new LinearGradientBrush(new Rectangle(0, 0, img.Width + 10, height), Color.Transparent, toBG, LinearGradientMode.Vertical);//The Brush that generates the fading effect to a specific color of your background.
bmp.SetResolution(img.HorizontalResolution, img.VerticalResolution);
using (Graphics grfx = Graphics.FromImage(bmp))
{
Bitmap bm = (Bitmap)img;
grfx.DrawImage(bm, 0, 0, img.Width, img.Height);
Bitmap bm1 = (Bitmap)img;
bm1.RotateFlip(RotateFlipType.Rotate180FlipX);
grfx.DrawImage(bm1, 0, img.Height);
Rectangle rt = new Rectangle(0, img.Height, img.Width, 100);
grfx.FillRectangle(brsh, rt);
}
return bmp;
}
}
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.Image = Mesoft.General.DrawReflection(pictureBox1.Image, Color.Black);
}
No comments:
Post a Comment