How to paint Areas of Picture
Posted on January 5, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 'Graphics - How to paint Areas of Picture Option Explicit 'Add a PictureBox to your form add a picture to the Picture Box 'Now click on the picture. Every area that been clicked will be painted. Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long Declare Function ExtFloodFill Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, _ ByVal crColor As Long, ByVal wFillType As Long) As Long Public Const FLOODFILLBORDER = 0 Public Const FLOODFILLSURFACE = 1 Private Sub Form_Load() Dim mBrush As Long mBrush = CreateSolidBrush(&H8080FF) SelectObject Picture1.hdc, mBrush Picture1.ScaleMode = vbPixels DeleteObject mBrush End Sub Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) ExtFloodFill Picture1.hdc, X, Y, GetPixel(Picture1.hdc, X, Y), FLOODFILLSURFACE End Sub |