private void button1_MouseDown(object sender, MouseEventArgs e)
{
Button btn = sender as Button;
using (Bitmap bmp = new Bitmap(btn.Width, btn.Height))
{
btn.DrawToBitmap(bmp, new Rectangle(Point.Empty, btn.Size));
using (Graphics gfx = Graphics.FromImage(bmp))
{
ColorMatrix matrix = new ColorMatrix();
matrix.Matrix33 = .5F;
ImageAttributes attributes = new ImageAttributes();
attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
gfx.DrawImage(bmp, new Rectangle(Point.Empty, bmp.Size));
Cursor cur = new Cursor(bmp.GetHicon());
Cursor.Current = cur;
}
}
}
It's supposed to draw the image with transparency but it's opaque. How do I add alpha channel info? My ultimate goal is to have an alpha channel gradient so the transparency increases as the image gets further away from a given point (usually the center or the left edge).
Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>
Our community of experts have been thoroughly vetted for their expertise and industry experience.