Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleUse BitBlt, StretchBlt, and PaintPicture and compare their speeds
KeywordsBitBlt, StretchBlt, PaintPicture, performance, copy picture
CategoriesControls, Graphics
 
Use BitBlt, StretchBlt, and PaintPicture repeatedly timing the tests.

My book Visual Basic Graphics Programming shows more ways to use BitBlt and StretchBlt.

Typically BitBlt and PaintBlt take about 0.1 seconds and PaintPicture takes about 1.76 seconds.

 
Private Sub cmdPaintPicture_Click()
Dim num_trials As Integer
Dim trial As Integer
Dim start_time As Single
Dim stop_time As Single
Dim wid As Single
Dim hgt As Single

    num_trials = CInt(txtTrials.Text)
    wid = picFrom.ScaleWidth
    hgt = picFrom.ScaleHeight

    lblTime.Caption = ""
    Screen.MousePointer = vbHourglass
    DoEvents
    start_time = Timer
    For trial = 1 To num_trials
        picTo.Cls
        picTo.Refresh
        picTo.PaintPicture picFrom.Picture, 0, 0
        picTo.Refresh
    Next trial
    DoEvents
    stop_time = Timer
    Screen.MousePointer = vbDefault

    lblTime.Caption = _
        Format$(stop_time - start_time, "0.0000") & _
        " sec"
End Sub

Private Sub cmdBitBlt_Click()
Dim num_trials As Integer
Dim trial As Integer
Dim start_time As Single
Dim stop_time As Single
Dim wid As Single
Dim hgt As Single

    num_trials = CInt(txtTrials.Text)
    wid = picFrom.ScaleWidth
    hgt = picFrom.ScaleHeight

    lblTime.Caption = ""
    Screen.MousePointer = vbHourglass
    DoEvents
    start_time = Timer
    For trial = 1 To num_trials
        picTo.Cls
        picTo.Refresh
        BitBlt picTo.hDC, 0, 0, wid, hgt, _
            picFrom.hDC, 0, 0, _
            SRCCOPY
        picTo.Refresh
    Next trial
    DoEvents
    stop_time = Timer
    Screen.MousePointer = vbDefault

    lblTime.Caption = _
        Format$(stop_time - start_time, "0.0000") & _
        " sec"
End Sub

Private Sub cmdStretchBlt_Click()
Dim num_trials As Integer
Dim trial As Integer
Dim start_time As Single
Dim stop_time As Single
Dim wid As Single
Dim hgt As Single

    num_trials = CInt(txtTrials.Text)
    wid = picFrom.ScaleWidth
    hgt = picFrom.ScaleHeight

    lblTime.Caption = ""
    Screen.MousePointer = vbHourglass
    DoEvents
    start_time = Timer
    For trial = 1 To num_trials
        picTo.Cls
        picTo.Refresh
        StretchBlt picTo.hDC, 0, 0, wid, hgt, _
            picFrom.hDC, 0, 0, wid, hgt, _
            SRCCOPY
        picTo.Refresh
    Next trial
    DoEvents
    stop_time = Timer
    Screen.MousePointer = vbDefault

    lblTime.Caption = _
        Format$(stop_time - start_time, "0.0000") & _
        " sec"
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated