Voici comment copier une image en définissant son opacité:
Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
Dim Image As Image = My.Resources._002tete
Dim ColorMatrix As New Imaging.ColorMatrix ColorMatrix.Matrix44 = 0.5
Dim ImageAttributes As New Imaging.ImageAttributes ImageAttributes.SetColorMatrix(ColorMatrix)
Dim ImgRect As New Rectangle(0, 0, Image.Width, Image.Height)
e.Graphics.DrawImage(Image, ImgRect, 0, 0, ImgRect.Width, ImgRect.Height, GraphicsUnit.Pixel, ImageAttributes)
End Sub
L'élément 4-4 définit l'opacité globale de l'image. Ici elle est définie sur 0.5, c'est à dire 50%. Dans mon exemple j'utilise une image provenant de My.Resources, mais il est évident qu'on peut utiliser n'importe quel image.
|