...
With that in mind, here is how I would optimize the loop:
Dim xMax As Integer
Dim yMax As Integer
xMax = p.Width - 1
yMax = p.Height - 1
For j = 0 To yMax
For i = 0 To xMax
c = r1.pixel(i,j)
r2.pixel(i,j) = RGB(255-c.red, 255-c.green, 255-c.blue)
Next
progress.prog.value=progress.prog.value+1
Next
Set the Progress.Maximum to equal the number of rows (height) instead
of the number of pixels like you had before. Notice that I switched
the rows and columns... it is only a theory, but it should be faster
...
In these cases, I also only update progress bars every 25 rows or so
(depends on the image size). Users can't tell the difference and
there is still a noticable speedup. In the above example, probably
90% or more of the code is in updating the progress bar.
Craig
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|