Looping through all the pixels in a picture box will be slow.
However I made a few changes to the code that makes it slighter faster.
I simply added more variables so you don't read property values more then once.
Checking the property value of an object is slower then using a variable.
You're also loop to picSrc.ScaleWidth and picSrc.ScaleHeight but it should be one less since the first pixel is at position 0,0 and not 1,1.Best regardsVB Code:
Private Sub cmdStart_Click() Dim x As Long, y As Long Dim startTime As Long Dim lngColor As Long Dim nSW As Long, nSH As Long Dim hSrcDC As Long, hDestDC As Long Dim blnRefresh As Boolean picDest.Cls hSrcDC = picSrc.hdc hDestDC = picDest.hdc blnRefresh = (chkRefresh.Value = vbChecked) nSW = picSrc.ScaleWidth - 1 'don't loop longer then necassary nSH = picSrc.ScaleHeight - 1 lblStatus.Caption = "Processing..." lblStatus.Refresh startTime = GetTickCount() For x = 0 To nSW For y = 0 To nSH lngColor = GetPixel(hSrcDC, x, y) SetPixel hDestDC, x, y, lngColor Next y If blnRefresh = True And x Mod 5 = 0 Then picDest.Refresh End If Next x lblStatus.Caption = "Done in " & (GetTickCount() - startTime) / 1000 & " seconds" picDest.Refresh End Sub




Reply With Quote