''' <summary>
''' Diese Funktion ändert die Farbe aller Pixel mit einer bestimmten Farben in einer neuen Farbe
''' </summary>
''' <param name="SourceImage">Das Bild dessen Pixel neu gezeichnet werden sollen</param>
''' <param name="OldColor">Die alte Farbe</param>
''' <param name="NewColor">Die neue Farbe</param>
Public Function PixelRePaint(ByVal SourceImage As Image, ByVal OldColor As Color, ByVal NewColor As Color) As Bitmap
Dim NewBitmap As New Bitmap(SourceImage.Width, SourceImage.Height)
Dim CMap(0) As ColorMap
CMap(0) = New ColorMap
CMap(0).OldColor = OldColor
CMap(0).NewColor = NewColor
Dim ImgAttr As New ImageAttributes
ImgAttr.SetRemapTable(CMap)
Using G As Graphics = Graphics.FromImage(NewBitmap)
G.DrawImage(SourceImage, _
New Rectangle(0, 0, SourceImage.Width, SourceImage.Height), 0, 0, _
SourceImage.Width, _
SourceImage.Height, _
GraphicsUnit.Pixel, _
ImgAttr)
End Using
Return NewBitmap
End Function