Hi there , ive been looking for ways to speed up my dynamic masking tool http://www.indigorose.com/forums/sho...&highlight=dmt and ive found out that creating a pointer to a bmp is over 10x faster than using the Pset() method of pixel manipulation .
In myprogram there is 2 forms with a picturebox on each one. I simply want to copy the pixels of a certain colorfrom Form1 to Form 2.At the moment the code im using is :
ive been trying to work though this tutorial http://www.xtremevbtalk.com/showthread.php?t=25347Code:Public Sub MergePics(ReadColor As Long, WriteColor As Long) Dim ScanX, ScanY, PixelColor As Long For ScanX = 0 To Form2.Picture1.ScaleWidth - 1 For ScanY = 0 To Form2.Picture1.ScaleHeight - 1 PixelColor = Form2.Picture1.Point(ScanX, ScanY) Form1.Picture1.PSet (ScanX, ScanY), WriteColor End If Next ScanY Next ScanX End Sub
The tutorial makes it all look so easy but to be honest im having a hard time working out how to do this.
The Demo prog is supposed to take a 100x100 bitmap and turn all the pixels red using 3 different methods showing the time taken for each one.
But the image only turns red twice even though a time of 350ish is displayed for the first operation. So thinking the first time might be to fast to see i cut the code down to just use the PicArray method;Code:Option Explicit Private Declare Function GetPixel Lib "gdi32" _ (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long Private Declare Function SetPixel Lib "gdi32" _ (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long Private Declare Function timeGetTime Lib "winmm.dll" () As Long Dim pa As BCHPicArray.clsPicArray Private Sub Command1_Click() Dim x&, y&, t& t = timeGetTime() For y = 0 To Picture1.ScaleHeight - 1 For x = 0 To Picture1.ScaleWidth - 1 pa.DrawPixel x, y, vbRed Next x Next y t = timeGetTime() - t Picture1.Refresh Me.Caption = "PicArray=" & t t = timeGetTime() For y = 0 To Picture1.ScaleHeight - 1 For x = 0 To Picture1.ScaleWidth - 1 SetPixel Picture1.hdc, x, y, vbRed Next x Next y t = timeGetTime() - t Picture1.Refresh Me.Caption = Me.Caption & " SetPixel=" & t t = timeGetTime() For y = 0 To Picture1.ScaleHeight - 1 For x = 0 To Picture1.ScaleWidth - 1 Picture1.PSet (x, y), vbRed Next x Next y t = timeGetTime() - t Picture1.Refresh Me.Caption = Me.Caption & " PSet=" & t End Sub Private Sub Form_Load() Set pa = New clsPicArray pa.LoadPicArray Picture1.Picture End Sub Private Sub Form_Unload(Cancel As Integer) Set pa = Nothing End Sub
But The pixels dont change to red. This tutorial is replicated all over the net so i cant see the code being wrong at all,but the forum where it was origionaly posted has closed the thread so i can ask the guy who wrote it. Ive included a copy of the tutorial in the zipfile rather than post it up here. Any help on this would be much appreciated. thanks.Code:Option Explicit Private Declare Function GetPixel Lib "gdi32" _ (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long Private Declare Function SetPixel Lib "gdi32" _ (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long Private Declare Function timeGetTime Lib "winmm.dll" () As Long Dim pa As BCHPicArray.clsPicArray Private Sub Form_Load() Set pa = New clsPicArray pa.LoadPicArray Picture1.Picture End Sub Private Sub Command1_Click() Dim x&, y&, t& For y = 0 To Picture1.ScaleHeight - 1 For x = 0 To Picture1.ScaleWidth - 1 pa.DrawPixel x, y, vbRed Next x Next y End Sub Private Sub Form_Unload(Cancel As Integer) Set pa = Nothing End Sub

