The trick is to use an alpha component while drawing the image.
// transparency should be in the range 0 to 1
protected void DrawScrollImage(Graphics g, Rectangle rect, Image image, float transparency)
{
ImageAttributes ia = new ImageAttributes();
ColorMatrix cm = new ColorMatrix();
cm.Matrix00 = 1;
cm.Matrix11 = 1;
cm.Matrix22 = 1;
cm.Matrix33 = transparency;
ia.SetColorMatrix(cm);
g.DrawImage(image, rect, 0, 0, image.Width, image.Height,
GraphicsUnit.Pixel, ia);
}
Share with