Results 1 to 3 of 3

Thread: SPEED UP THIS CODE!!

  1. #1
    Guest
    I'm using this function to tile a picture to an object, and I need this as fast as humanly possible!!
    It really starts to lag when the object is full screen using any type of picture.

    Ready? SPEED UP THIS CODE!!!
    Code:
    Public Sub TileImage(RefObject As Object, ImageToTile As PictureBox)
    Dim lngX&, lngY&, lngBitmapHandle&, lngFormHeight&, lngFormWidth&
    Dim lngPictureHeight&, lngPictureWidth&
    Dim lngPrevScale&, lngRet&, lngSourceDC&
    
    On Error GoTo Err
    
    With ImageToTile
        lngPrevScale = .ScaleMode
        .ScaleMode = vbPixels
        lngPictureHeight = .ScaleHeight
        lngPictureWidth = .ScaleWidth
        .ScaleMode = lngPrevScale
    End With
    
    With RefObject
        lngPrevScale = .ScaleMode
        .ScaleMode = vbPixels
        lngFormHeight = .ScaleHeight
        lngFormWidth = .ScaleWidth
        .ScaleMode = lngPrevScale
    End With
    
    lngSourceDC = CreateCompatibleDC(RefObject.hdc)
    lngBitmapHandle = SelectObject(lngSourceDC, ImageToTile.Picture.Handle)
    
    'core tiling routine
    For lngY = 0 To lngFormHeight Step lngPictureHeight
        For lngX = 0 To lngFormWidth Step lngPictureWidth
            lngRet = BitBlt(RefObject.hdc, lngX, lngY, lngPictureWidth, lngPictureHeight, RefObject.hdc, 0, 0, SRCCOPY)
        Next lngX
    Next lngY
    
    lngRet = SelectObject(lngSourceDC, lngBitmapHandle)
    lngRet = DeleteDC(lngSourceDC)
    
    Exit Sub
    
    Err:
    If Not RefObject Is Nothing Then
        RefObject.Tag = Err.Number & "  " & Err.Description
        Debug.Print (Err.Number & "  " & Err.Description)
        End If
    End Sub
    Please post ANY and ALL suggestions/code snippets that will speed this up!!

    Thanks,

    Joe Jordan

  2. #2
    New Member
    Join Date
    Jul 2000
    Location
    Belguim
    Posts
    15

    Thumbs up Direct Draw

    Hi,

    If you want to create very fast tiling then i have the answer use directx7 direct draw.

    If you don't now how to use it then mail your e-mail addres to:
    [email protected]
    Then i send a direct draw control to you from GabitaSoft Belguim (FreeWare).

    Regards
    GabitaSoft (Sigurd)

  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    What speed is your PC? it works fine on mine (PIII 600), although your BitBlt line should be:
    Code:
    lngRet = BitBlt(RefObject.hdc, lngX, lngY, lngPictureWidth, lngPictureHeight, lngSourceDC, 0, 0, SRCCOPY)

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