Results 1 to 3 of 3

Thread: Color Fill

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    9

    Question

    I need to fill some closed regions. Is there an API to do this?
    Thanks

  2. #2
    Guest

    Answer

    Look at this site http://www.vbapi.com
    there is the right API- call with example

  3. #3
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    This should really explain the filling API:
    Code:
    Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
    Private 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
    Const FLOODFILLBORDER = 0 ' Fill until crColor& color encountered.
    Const FLOODFILLSURFACE = 1 ' Fill surface until crColor& color not encountered.
    Const crNewColor = &HFFFF80
    Dim mBrush As Long
    Private Sub Form_Load()
        'Create a solid brush
        mBrush = CreateSolidBrush(crNewColor)
        'Select the brush into the PictureBox' device context
        SelectObject Picture1.hdc, mBrush
        'API uses pixels
        Picture1.ScaleMode = vbPixels
    End Sub
    Private Sub Form_Unload(Cancel As Integer)
        'Delete our new brush    
        DeleteObject mBrush
    End Sub
    Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
        'Floodfill...
        ExtFloodFill Picture1.hdc, x, y, GetPixel(Picture1.hdc, x, y), FLOODFILLSURFACE
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width