1 Attachment(s)
[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?
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)?