|
-
Dec 28th, 2001, 12:06 AM
#1
-
Dec 28th, 2001, 01:18 AM
#2
PowerPoster
SetPixelV is supposed to be faster, but I didn't see any difference in speed when I tried it. Can't you just BitBlt the whole image at once, and it will go a lot faster? Look what I did to the project and you see if you can do this.
-
Dec 28th, 2001, 01:24 AM
#3
-
Dec 28th, 2001, 01:27 AM
#4
PowerPoster
I don't think you are going to get any faster without using somthing other than setpixel. I don't know of any other way to do it though. What if you bitblt the image, and then use setpixel to change only pixels that you want to add the effects to? I don't know how to do that, but it sounds like it would work in theory. (And everything works in theory )
-
Dec 28th, 2001, 01:29 AM
#5
hehehe, I hope it was that easy
what if I want to edit all the pixels!!?!!!
-
Dec 28th, 2001, 01:34 AM
#6
PowerPoster
If you want to edit all the pixels, then your SOL (***** Outta Luck) . You will just have to deal with the slow .8 seconds it takes to do that. What's wrong with .8 seconds anyway?
-
Dec 28th, 2001, 01:46 AM
#7
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.
VB 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
Best regards
-
Dec 28th, 2001, 01:55 AM
#8
hehehe, I never realized that those factors make the code slower... thanks alot
But there should be a faster way though
-
Dec 28th, 2001, 01:19 PM
#9
I'm still looking for a solution, please help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|