Public Function SetImageAlpha(ByVal Image As Image, ByVal Alpha As Single) As Image
Dim ImgAttr As New Imaging.ImageAttributes()
'Standard-ColorMatrix für Transparenz
Dim ColorMatrix As New Imaging.ColorMatrix(New Single()() {New Single() {1, 0, 0, 0, 0}, New Single() {0, 1, 0, 0, 0}, New Single() {0, 0, 1, 0, 0}, New Single() {0, 0, 0, CSng(Alpha / 100), 0}, New Single() {0, 0, 0, 0, 1}})
'ColorMatrix an ImageAttribute-Objekt übergeben
ImgAttr.SetColorMatrix(ColorMatrix)
'Neue 32bit Bitmap erstellen
Dim NewBitmap = New Bitmap(Image.Width, Image.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
'Resolution (DPI) vom Quellbitmap auf Zielbitmap übertragen
NewBitmap.SetResolution(Image.HorizontalResolution, Image.VerticalResolution)
'Graphicsobjekt von NewBitmap erstellen
Dim NewGraphics As Graphics = Graphics.FromImage(NewBitmap)
'NewBitmap auf NewGraphics zeichnen
NewGraphics.DrawImage(Image, New Rectangle(0, 0, NewBitmap.Width, NewBitmap.Height), 0, 0, Image.Width, Image.Height, GraphicsUnit.Pixel, ImgAttr)
'Ressource freigeben
NewGraphics.Dispose()
ImgAttr.Dispose()
Return NewBitmap
End Function