Korrektur-Pinsel Soften


Mit dem Korrektur-Pinsel Soften können Sie Teile eines Bildes nachträglich und pinselgenau weichzeichnen.
Laden Sie sich die Zip-Datei mit VB 6 Source Code hinunter und probieren Sie es mal aus.

Projekt - Download
© FienauBerlin   Web-ComputerEcke.de
 

Quell-Code Form1
Option Explicit
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, _
                                 X As Single, Y As Single)
   shCircle.Visible = False
End Sub

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, _ X As Single, Y As Single) Picture1.AutoRedraw = True SoftenBlur Picture1.hDC, X, Y, (Val(HScroll1.Value) / 2), _ Val(3), Abs(HScroll2.Value - 255) '1 - 100 DoEvents Picture1.Refresh DoEvents End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, _ X As Single, Y As Single) shCircle.Visible = True shCircle.Width = HScroll1.Value shCircle.Height = shCircle.Width shCircle.Left = X - HScroll1.Value / 2 shCircle.Top = Y - HScroll1.Value / 2 If Button = 1 Then SoftenBlur Picture1.hDC, X, Y, (Val(HScroll1.Value) / 2), Val(3), _ Abs(HScroll2.Value - 255) '1 - 100 DoEvents Picture1.Refresh DoEvents Exit Sub End If End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, _ X As Single, Y As Single) Picture1.AutoRedraw = False End Sub

Quell-Code Module1
Option Explicit
 
Private Declare Function SetPixelV Lib "gdi32" (ByVal hDC As Long, _
           ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
 
Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, _
           ByVal Y As Long) As Long

Public Sub SoftenBlur(Target As Long, X As Single, Y As Single, _ radius As Long, Steps As Long, Alpha As Integer) Dim cX As Long Dim cY As Long Dim TempColor(3) As Long Dim TempRadius As Integer Dim I As Integer Dim u As Integer Dim Red(3) As Long Dim Green(3) As Long Dim Blue(3) As Long Dim Color0 As Long Dim Color1 As Long Dim Color2 As Long Dim Color3 As Long Dim Done() As Boolean ReDim Done(-radius To radius, -radius To radius) For I = 1 To Steps TempRadius = radius / Steps * I For cX = -TempRadius To TempRadius 'Step 2 For cY = -TempRadius To TempRadius 'Step 2 If Not Done(cX, cY) Then If (cX * cX) + (cY * cY) <= TempRadius * TempRadius Then TempColor(0) = GetPixel(Target, cX + X, cY + Y) TempColor(1) = GetPixel(Target, cX + X, cY + Y - 1) TempColor(2) = GetPixel(Target, cX + X - 1, cY + Y - 1) TempColor(3) = GetPixel(Target, cX + X - 1, cY + Y) For u = 0 To 3 '==> RGB + Fehlerbehandlung Blue(u) = TempColor(u) \ 65536 Green(u) = (TempColor(u) - Blue(u) * 65536) \ 256 Red(u) = TempColor(u) - Blue(u) * 65536 - Green(u) * 256 If Red(u) < 0 Then Red(u) = 0 If Red(u) > 255 Then Red(u) = 255 If Green(u) < 0 Then Green(u) = 0 If Green(u) > 255 Then Green(u) = 255 If Blue(u) < 0 Then Blue(u) = 0 If Blue(u) > 255 Then Blue(u) = 255 Next u Color0 = RGB(((Red(0) * Alpha) + Red(1) + Red(2) + Red(3)) / (Alpha + 3), _ ((Green(0) * Alpha) + Green(1) + Green(2) + Green(3)) / (Alpha + 3), _ ((Blue(0) * Alpha) + Blue(1) + Blue(2) + Blue(3)) / (Alpha + 3)) Color1 = RGB((Red(0) + (Red(1) * Alpha) + Red(2) + Red(3)) / (Alpha + 3), _ (Green(0) + (Green(1) * Alpha) + Green(2) + Green(3)) / (Alpha + 3), _ (Blue(0) + (Blue(1) * Alpha) + Blue(2) + Blue(3)) / (Alpha + 3)) Color2 = RGB((Red(0) + Red(1) + (Red(2) * Alpha) + Red(3)) / (Alpha + 3), _ (Green(0) + Green(1) + (Green(2) * Alpha) + Green(3)) / (Alpha + 3), _ (Blue(0) + Blue(1) + (Blue(2) * Alpha) + Blue(3)) / (Alpha + 3)) Color3 = RGB((Red(0) + Red(1) + Red(2) + (Red(3) * Alpha)) / (Alpha + 3), _ (Green(0) + Green(1) + Green(2) + (Green(3) * Alpha)) / (Alpha + 3), _ (Blue(0) + Blue(1) + Blue(2) + (Blue(3) * Alpha)) / (Alpha + 3)) SetPixelV Target, cX + X, cY + Y, Color0 SetPixelV Target, cX + X, cY + Y - 1, Color1 SetPixelV Target, cX + X - 1, cY + Y - 1, Color2 SetPixelV Target, cX + X - 1, cY + Y, Color3 Done(cX, cY) = True End If End If Next cY Next cX Next I End Sub