Results 1 to 2 of 2

Thread: BitBlt slooooow as hell

  1. #1

    Thread Starter
    Addicted Member Vegeta's Avatar
    Join Date
    Jul 2002
    Posts
    159

    Angry BitBlt slooooow as hell

    I used this code to capture the entire screen and to write the bitmap into an array:

    VB Code:
    1. Dim bBytes(1 To 2359296) As Byte
    2.     Dim hdc0 As Long
    3.     Dim idc As Long
    4.     Dim ibitmap As Long
    5.    
    6.     With bi24BitInfo.bmiHeader
    7.         .biBitCount = 24
    8.         .biCompression = BI_RGB
    9.         .biPlanes = 1
    10.         .biSize = Len(bi24BitInfo.bmiHeader)
    11.         .biWidth = 1024
    12.         .biHeight = 768
    13.     End With
    14.  
    15.     hdc0 = GetDC(0)
    16.     idc = CreateCompatibleDC(0)
    17.  
    18.     ibitmap = CreateDIBSection(idc, bi24BitInfo, DIB_RGB_COLORS, ByVal 0&, ByVal 0&, ByVal 0&)
    19.    
    20.     SelectObject idc, ibitmap
    21.     BitBlt idc, 0, 0, bi24BitInfo.bmiHeader.biWidth, bi24BitInfo.bmiHeader.biHeight, hdc0, 0, 0, vbSrcCopy
    22.     GetDIBits hdc0, ibitmap, 0, bi24BitInfo.bmiHeader.biHeight, bBytes(1), bi24BitInfo, DIB_RGB_COLORS

    it took ~ 500 ms to perform this code as compiled application.
    i found out that the line with the bitblt call takes ~ 460ms.
    but why so long? this command only copies 2,3 MB from one memory block to the other.... that cant take 500 ms...
    how can I optimate this line of code?

    thanks for any help

  2. #2
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    You could use hardware support to quicken up the blt.

    Direct draw has FastBlt and you can also use GDI+ to perform the bitblt. Both these methods are hardware compatible so any available hardware(video card) that has some decent 2d support should execute the code nearly instantly.

    There is even a wrapper DLL so you can use GDI+ without writing your own C DLL.

    Do a google search.

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