' MsgBox(BMP.Width & " " & BMP.Height)
For x As Integer = 0 To BMP.Width - 1 ' Val(Me.Breite.Text) - 1 ' Val( _
Me.XPos.Text) + 1 To Val(Me.Breite.Text) - 1
For y As Integer = 0 To BMP.Height - 1 ' Val(Me.Höhe.Text) - 1 'Val( _
Me.YPos.Text) + 1 To Val(Me.Höhe.Text) - 1
'MsgBox(BMP.GetPixel(x, y).ToString & " " &
' Me.AktuelleFarbe.Text)
BearbeiteteAktuelleFarbe.Text = BMP.GetPixel(x, y).ToString
AktuellA = Mid(BearbeiteteAktuelleFarbe.Text, InStr(1, _
BearbeiteteAktuelleFarbe.Text, "A=") + 2, 3)
AktuellR = Mid(BearbeiteteAktuelleFarbe.Text, InStr(1, _
BearbeiteteAktuelleFarbe.Text, "R=") + 2, 3)
AktuellG = Mid(BearbeiteteAktuelleFarbe.Text, InStr(1, _
BearbeiteteAktuelleFarbe.Text, "G=") + 2, 3)
AktuellB = Val(Mid(BearbeiteteAktuelleFarbe.Text, InStr(1, _
BearbeiteteAktuelleFarbe.Text, "B=") + 2, 3))
' If BMP.GetPixel(x, y).ToString = Me.AktuelleFarbe.Text Then
' 'Or BMP.GetPixel(x, y).ToString = "Color [A=255, R=252," & _
"G=255, B=255]" Or BMP.GetPixel(x, y).A = 0 Or BMP.GetPixel(x, _
y).R > 250 Or BMP.GetPixel(x, y).G > 250 Or BMP.GetPixel( _
x, y).B > 250 Then
' If AktuelleFarbeA=AktuellA and AktuelleFarbeR=AktuellR and
' AktuelleFarbeG=AktuellG and AktuelleFarbeB=AktuellB and
If Abweichnung_Farbwert(AktuellR, AktuelleFarbeR.Text, "R") = _
True And Abweichnung_Farbwert(AktuellG, AktuelleFarbeG.Text, _
"G") = True And Abweichnung_Farbwert(AktuellB, _
AktuelleFarbeB.Text, "B") = True Then
' If AktuelleFarbeR = AktuellR And AktuelleFarbeG =
' AktuellG And AktuelleFarbeB = AktuellB Then
BMP.SetPixel(x, y, Color.Transparent)
End If
Next
'MsgBox("")
Next
BildAnzeigeNeu.Image = BMP
BildAnzeigeNeu.Refresh()
Cursor = Cursors.Arrow
End Sub
Public Function ReplaceColor(ByVal oBitmap As Image, ByVal OldColor As _
Color, ByVal NewColor As Color) As Image
' ColorMap mit Zuweisung der zu konvertierenden
' Farben(erstellen)
Dim oMap(0) As ColorMap
oMap(0) = New ColorMap
With oMap(0)
.OldColor = OldColor
.NewColor = NewColor
End With
' ImageAttributes-Objekt mit Farbanpassung erstellen
Dim oAttr As New ImageAttributes
oAttr.SetRemapTable(oMap)
' Neues Image-Objektop erstellen
Dim imgWidth As Integer = oBitmap.Width
Dim imgHeight As Integer = oBitmap.Height
Dim oImage As Image = Image.FromHbitmap(New Bitmap(imgWidth, _
imgHeight).GetHbitmap)
Using g As Graphics = Graphics.FromImage(oImage)
g.DrawImage(oBitmap, New Rectangle(0, 0, imgWidth, imgHeight), 0, _
0, imgWidth, imgHeight, GraphicsUnit.Pixel, oAttr)
End Using
' neues Bild zurückgeben
Return oImage
End Function
Function Abweichnung_Farbwert(ByVal Farbwert1 As Integer, ByVal Farbwert2 As _
Integer, ByVal Farbe As String) As Boolean
Abweichnung_Farbwert = False
Dim DIff As Integer
DIff = System.Math.Abs(Farbwert1 - Farbwert2)
Select Case Farbe
Case "A"
If DIff <= My.Settings.FarbAbweichungA Then ' DIff >=
' My.Settings.AbweichungA * -1 And DIff <=
' My.Settings.AbweichungA Then
Abweichnung_Farbwert = True
End If
Case "R"
If DIff <= My.Settings.FarbAbweichungR Then 'DIff >=
' My.Settings.AbweichungR * -1 And DIff <=
' My.Settings.AbweichungR Then
Abweichnung_Farbwert = True
End If
Case "G"
If DIff <= My.Settings.FarbAbweichungG Then ' DIff >=
' My.Settings.AbweichungG * -1 And DIff <=
' My.Settings.AbweichungG Then
Abweichnung_Farbwert = True
End If
Case "B"
If DIff <= My.Settings.FarbAbweichungB Then 'DIff >=
' My.Settings.AbweichungB * -1 And DIff <=
' My.Settings.AbweichungB Then
Abweichnung_Farbwert = True
End If
End Select
End Function
Beitrag wurde zuletzt am 16.02.13 um 11:24:11 editiert. |