怎样创建位图,然后创建刷子,并用刷子在PictureBox里画图,最好给源码。谢···

解决方案 »

  1.   

    :|
    我不是高手!只是一个小例子'这个程序演示如何将一个BMP位图作为刷子填充整个窗口Private Type LOGBRUSH
            lbStyle As Integer
            lbColor As Long
            lbHatch As Long
    End TypePrivate Type POINTAPI
            x As Long
            y As Long
    End TypePrivate Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long
    Private Declare Function LineTo 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 LongPrivate Declare Function CreateBrushIndirect Lib "gdi32" (lpLogBrush As LOGBRUSH) As Long
    Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    Private Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    Private Declare Function ExtCreatePen Lib "gdi32" (ByVal dwPenStyle As Long, ByVal dwWidth As Long, lplb As Any, ByVal dwStyleCount As Long, ByVal lpStyle As Any) As LongConst PS_GEOMETRIC = &H10000
    Const PS_SOLID = 0
    Const PS_ENDCAP_MASK = &HF00Const BS_PATTERN = 3
    Const BS_PATTERN8X8 = 7Const DIB_RGB_COLORS = 0Private Sub Form_Load()
        Picture1.Visible = False
    End SubPrivate Sub Form_Paint()
        Dim lOldBrush As Long
        Dim lOldPen As Long
        Dim lBrush As Long
        Dim lPen As Long
        Dim l1 As Long
        Dim ap As POINTAPI
        Dim tLogBrush As LOGBRUSH
        
        lBrush = CreatePatternBrush(Picture1.Image)
        lOldBrush = SelectObject(Me.hdc, lBrush)
        If ExtFloodFill(Me.hdc, 3, 0, 25&, 0&) Then
        End If
        lBrush = SelectObject(Me.hdc, lOldBrush)
        If DeleteObject(lBrush) Then
        End If
    End Sub
      

  2.   


    在画之前先将Picture1的AutoRedraw属性设为True画好之后用SavePicture Picture1.Image, "f:\abc.bmp"就可以保存位图了