Results 1 to 2 of 2

Thread: Kedaman - Question

  1. #1
    Guest
    I have a question about something you said about a piece of code posted (by denniswrenn) a while back:

    Code:
    Public Function TileImage(RefForm As Form, ImageToTile As PictureBox) As Boolean
    On Error GoTo error_TileImage
    Dim lngBitmapHandle As Long
    Dim lngFormHeight As Long
    Dim lngFormWidth As Long
    Dim lngPictureHeight As Long
    Dim lngPictureWidth As Long
    Dim lngPrevScale As Long
    Dim lngRet As Long
    Dim lngSourceDC As Long
    Dim lngX As Long
    Dim lngY As Long
    
    If Not RefForm Is Nothing And Not ImageToTile Is Nothing Then
    
    With ImageToTile
        lngPrevScale = .ScaleMode
        .ScaleMode = vbPixels
        lngPictureHeight = .ScaleHeight
        lngPictureWidth = .ScaleWidth
        .ScaleMode = lngPrevScale
    End With
    
    With RefForm
        lngPrevScale = .ScaleMode
        .ScaleMode = vbPixels
        lngFormHeight = .ScaleHeight
        lngFormWidth = .ScaleHeight
        .ScaleMode = lngPrevScale
    End With
    
    lngSourceDC = CreateCompatibleDC(RefForm.hdc)
    lngBitmapHandle = SelectObject(lngSourceDC, ImageToTile.Picture.Handle)
    
    For lngX = 0 To lngFormWidth Step lngPictureWidth
        For lngY = 0 To lngFormHeight Step lngPictureHeight
            lngRet = BitBlt(RefForm.hdc, lngX, lngY, lngPictureWidth, lngPictureHeight, lngSourceDC, 0, 0, SRCCOPY)
        Next lngY
    Next lngX
    
    lngRet = SelectObject(lngSourceDC, lngBitmapHandle)
    lngRet = DeleteDC(lngSourceDC)
    
    TileImage = True
    
    Else
    TileImage = False
    End If
    Exit Function
    error_TileImage:
    If Not RefForm Is Nothing Then
        RefForm.Tag = Err.Number & "  " & Err.Description
        End If
        TileImage = False
    End Function
    ... Also Dennis, you don't need to create your own DC's, and you only need to declare two variables.
    I tried editing out the CreateCompatibleDC call, but I couldn't get it to function properly.
    I need this function to be as fast as possible so any clarification on what you said
    would be much appreciated!

    btw - The original thread was posted here: http://forums.vb-world.net/showthrea...threadid=17778

    Thanks,
    Jordan

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    First of all, what are you trying to do? You need createcompatibleDC for what?
    Code:
    RetDC = CreateCompatibleDC(hdc)
    You should pass a DC from a form or picturebox.



    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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