VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   4620
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   12465
   LinkTopic       =   "Form1"
   ScaleHeight     =   4620
   ScaleWidth      =   12465
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   4335
      Left            =   10920
      TabIndex        =   2
      Top             =   120
      Width           =   1455
   End
   Begin VB.PictureBox Pic2 
      BackColor       =   &H00000000&
      BorderStyle     =   0  'None
      FillStyle       =   0  'Solid
      Height          =   975
      Left            =   1080
      ScaleHeight     =   65
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   81
      TabIndex        =   1
      Top             =   120
      Width           =   1215
   End
   Begin VB.PictureBox Pic1 
      AutoSize        =   -1  'True
      BackColor       =   &H00000000&
      BorderStyle     =   0  'None
      FillStyle       =   0  'Solid
      Height          =   945
      Left            =   120
      ScaleHeight     =   63
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   60
      TabIndex        =   0
      Top             =   120
      Width           =   900
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim i As Integer
Dim j As Integer
Dim k As Integer
Private Sub Command1_Click()
    Call Blur(Pic1, Pic2, 10)
End Sub
Private Sub Form_Activate()
    Randomize Timer
    Pic1.FillStyle = vbSolid
    For i = 1 To Pic1.ScaleWidth * 2
        Pic1.FillColor = vbWhite
        Pic1.Circle (((Rnd * Pic1.ScaleWidth) / 1.25) + (Pic1.ScaleWidth * 1 / (10)), ((Rnd * Pic1.ScaleHeight) / 1.25) + (Pic1.ScaleHeight * 1 / (10))), Rnd * Pic1.ScaleHeight / 10, vbWhite
        Pic1.FillColor = vbBlack
        Pic1.Circle (((Rnd * Pic1.ScaleHeight) / 1.25) + (Pic1.ScaleWidth * 1 / (10)), ((Rnd * Pic1.ScaleHeight) / 1.25) + (Pic1.ScaleHeight * 1 / (10))), Rnd * Pic1.ScaleHeight / 15, vbBlack
    Next i
End Sub
Private Sub Form_Load()
    Pic2.Height = Pic1.Height
    Pic2.Width = Pic1.Width
End Sub
Private Function RedCol(Colour)
    RedCol = (Colour And &HFF)
End Function
Private Function GreenCol(Colour)
    GreenCol = (Colour \ &H100&) And &HFF&
End Function
Private Function BlueCol(Colour)
    BlueCol = (Colour \ &H10000) And &HFF&
End Function
Private Sub Blur(P1 As PictureBox, P2 As PictureBox, Itterations As Byte)
    Dim Red As Integer
    Dim Green As Integer
    Dim Blue As Integer
    For k = 1 To Itterations
        For i = 0 To P1.ScaleWidth
            P2.PSet (i, 0), P1.Point(i, 0)
            P2.PSet (i, P1.ScaleHeight - 1), P1.Point(i, P1.ScaleHeight - 1)
            DoEvents
        Next i
        For i = 0 To P1.ScaleHeight
            P2.PSet (0, i), P1.Point(0, i)
            P2.PSet (P1.ScaleWidth - 1, i), P1.Point(P1.ScaleWidth - 1, i)
            DoEvents
        Next i
        
        For i = 1 To P1.ScaleWidth - 2
            For j = 1 To P1.ScaleHeight - 2
                Red = (RedCol(P1.Point(i + 1, j + 1)) + RedCol(P1.Point(i + 1, j)) + RedCol(P1.Point(i + 1, j - 1)) + RedCol(P1.Point(i, j + 1)) + RedCol(P1.Point(i, j - 1)) + RedCol(P1.Point(i - 1, j + 1)) + RedCol(P1.Point(i - 1, j)) + RedCol(P1.Point(i - 1, j - 1))) / 8
                Green = (GreenCol(P1.Point(i + 1, j + 1)) + GreenCol(P1.Point(i + 1, j)) + GreenCol(P1.Point(i + 1, j - 1)) + GreenCol(P1.Point(i, j + 1)) + GreenCol(P1.Point(i, j - 1)) + GreenCol(P1.Point(i - 1, j + 1)) + GreenCol(P1.Point(i - 1, j)) + GreenCol(P1.Point(i - 1, j - 1))) / 8
                Blue = (BlueCol(P1.Point(i + 1, j + 1)) + BlueCol(P1.Point(i + 1, j)) + BlueCol(P1.Point(i + 1, j - 1)) + BlueCol(P1.Point(i, j + 1)) + BlueCol(P1.Point(i, j - 1)) + BlueCol(P1.Point(i - 1, j + 1)) + BlueCol(P1.Point(i - 1, j)) + BlueCol(P1.Point(i - 1, j - 1))) / 8
                P2.PSet (i, j), RGB(Red, Green, Blue)
                DoEvents
            Next j
        Next i
        
        For i = 0 To P1.ScaleWidth
            P2.PSet (i, 0), P1.Point(i, 0)
            P2.PSet (i, P1.ScaleHeight), P1.Point(i, P1.ScaleHeight)
            DoEvents
        Next i
        For i = 0 To P1.ScaleHeight
            P2.PSet (0, i), P1.Point(0, i)
            P2.PSet (P1.ScaleWidth, i), P1.Point(P1.ScaleWidth, i)
            DoEvents
        Next i

        P1.Picture = Nothing
        For i = 0 To P1.ScaleWidth
            For j = 0 To P1.ScaleHeight
                P1.PSet (i, j), P2.Point(i, j)
                DoEvents
            Next j
        Next i
    Next k
End Sub
