Results 1 to 2 of 2

Thread: [VB6 - DIB's] - advices for speed up my Graphic Class

  1. #1

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    [VB6 - DIB's] - advices for speed up my Graphic Class

    i need advices for speed my class. it takes very time to Draw the image

    - GetImageData sub: here is catch the image from a control(picturebox and form and usercontrol);
    - ChangeImage sub: here i change the image pixels;
    - DrawImage sub: is for draw the image.

    i see more when i tiled the image. can anyone advice for speed up my class?
    Attached Files Attached Files
    VB6 2D Sprite control

    To live is difficult, but we do it.

  2. #2

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6 - DIB's] - advices for speed up my Graphic Class

    i have did some changes and i have seen the tiles need very time to be showed
    Code:
    Public Sub DrawImage(Picture As Object, Optional x As Long = 0, Optional y As Long = 0, Optional Width As Long = 0, Optional Height As Long = 0)
        Dim lngTileX As Long
        Dim lngTileY As Long
        Dim lngTileLimitX As Long
        Dim lngTileLimitY As Long
        
        Call ChangeImage
        If Width = 0 Then Width = outWidth
        If Height = 0 Then Height = outHeight
            
        With bi32BitInfo.bmiHeader
            .biBitCount = 32
            .biPlanes = 1
            .biSize = Len(bi32BitInfo.bmiHeader)
            .biWidth = outWidth
            .biHeight = outHeight
            .biSizeImage = 4 * outWidth * outHeight
        End With
    
          
        'draw image transparent or not
        'draw image mirrored or not
        If blnTiles = True Then
            lngTileLimitX = Picture.ScaleWidth
            lngTileLimitY = Picture.ScaleHeight
        Else
            lngTileLimitX = 1
            lngTileLimitY = 1
        End If
        
        For lngTileY = 0 To lngTileLimitY Step outHeight
            For lngTileX = 0 To lngTileLimitX Step outWidth
                If msMirrorState = None Then
                    If blnTransparent = False Then
                        StretchDIBits Picture.hdc, lngTileX, lngTileY, Width, Height, 0, 0, _
                            outWidth, outHeight, ChangedImage(0, 0), bi32BitInfo, 0, vbSrcCopy
                    ElseIf blnTransparent = True Then
                        StretchDIBits Picture.hdc, lngTileX, lngTileY, Width, Height, 0, 0, _
                            outWidth, outHeight, ChangedImage(0, 0), bi32BitInfo, 0, vbSrcInvert
                        StretchDIBits Picture.hdc, lngTileX, lngTileY, Width, Height, 0, 0, _
                            outWidth, outHeight, MaskImage(0, 0), bi32BitInfo, 0, vbSrcAnd
                        StretchDIBits Picture.hdc, lngTileX, lngTileY, Width, Height, 0, 0, _
                            outWidth, outHeight, ChangedImage(0, 0), bi32BitInfo, 0, vbSrcInvert
                    End If
                ElseIf msMirrorState = Horizontal Then
                    If blnTransparent = False Then
                        StretchDIBits Picture.hdc, Width + lngTileX, lngTileY, -Width, Height, 0, 0, _
                            outWidth, outHeight, ChangedImage(0, 0), bi32BitInfo, 0, vbSrcCopy
                    ElseIf blnTransparent = True Then
                        StretchDIBits Picture.hdc, Width + lngTileX, lngTileY, -Width, Height, 0, 0, _
                            outWidth, outHeight, ChangedImage(0, 0), bi32BitInfo, 0, vbSrcInvert
                        StretchDIBits Picture.hdc, Width + lngTileX, lngTileY, -Width, Height, 0, 0, _
                            outWidth, outHeight, MaskImage(0, 0), bi32BitInfo, 0, vbSrcAnd
                        StretchDIBits Picture.hdc, Width + lngTileX, lngTileY, -Width, Height, 0, 0, _
                            outWidth, outHeight, ChangedImage(0, 0), bi32BitInfo, 0, vbSrcInvert
                    End If
                ElseIf msMirrorState = Vertical Then
                    If blnTransparent = False Then
                        StretchDIBits Picture.hdc, lngTileX, Height + lngTileY, Width, -Height, 0, 0, _
                            outWidth, outHeight, ChangedImage(0, 0), bi32BitInfo, 0, vbSrcCopy
                    ElseIf blnTransparent = True Then
                        StretchDIBits Picture.hdc, lngTileX, Height + lngTileY, Width, -Height, 0, 0, _
                            outWidth, outHeight, ChangedImage(0, 0), bi32BitInfo, 0, vbSrcInvert
                        StretchDIBits Picture.hdc, lngTileX, Height + lngTileY, Width, -Height, 0, 0, _
                            outWidth, outHeight, MaskImage(0, 0), bi32BitInfo, 0, vbSrcAnd
                        StretchDIBits Picture.hdc, lngTileX, Height + lngTileY, Width, -Height, 0, 0, _
                            outWidth, outHeight, ChangedImage(0, 0), bi32BitInfo, 0, vbSrcInvert
                    End If
                ElseIf msMirrorState = HorizontalVertical Then
                    If blnTransparent = False Then
                        StretchDIBits Picture.hdc, Width + lngTileX, Height + lngTileY, -Width, -Height, 0, 0, _
                            outWidth, outHeight, ChangedImage(0, 0), bi32BitInfo, 0, vbSrcCopy
                    ElseIf blnTransparent = True Then
                        StretchDIBits Picture.hdc, Width + lngTileX, Height + lngTileY, -Width, -Height, 0, 0, _
                            outWidth, outHeight, ChangedImage(0, 0), bi32BitInfo, 0, vbSrcInvert
                        StretchDIBits Picture.hdc, Width + lngTileX, Height + lngTileY, -Width, -Height, 0, 0, _
                            outWidth, outHeight, MaskImage(0, 0), bi32BitInfo, 0, vbSrcAnd
                        StretchDIBits Picture.hdc, Width + lngTileX, Height + lngTileY, -Width, -Height, 0, 0, _
                            outWidth, outHeight, ChangedImage(0, 0), bi32BitInfo, 0, vbSrcInvert
                    End If
                End If
            Next lngTileX
        Next lngTileY
    End Sub
    someone can advice me how can i speed up these for's(that i use for show the image and tile it, if is selected)?
    VB6 2D Sprite control

    To live is difficult, but we do it.

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