The code below subtracts two images from one another and determines if
there is any new things in the picture. A large enough color change
will "register" a pixel. The pixel is then plotted using SetPixel call.
On the form picture3 changes, but if I refresh it shows nothing. The
same happens when I save it. It saves an image that is "creamy white"
in color.
I tried messing with CreateCompatibleDC, of the image, and then set the
pixels using this device context but I unfamiliar really with DC's and
all the jazz.
Thanks for any help.
-----------------------------------
For j = 0 To Form1.Picture1.ScaleHeight
For i = 0 To Form1.Picture1.ScaleWidth
tcol1 = GetPixel(Form1.Picture1.hdc, i, j)
tcol2 = GetPixel(Form1.Picture2.hdc, i, j)
r1 = tcol1 Mod 256
g1 = (tcol1 Mod 256) \ 256
b1 = tcol1 \ 256 \ 256
r2 = tcol2 Mod 256
g2 = (tcol2 Mod 256) \ 256
b2 = tcol2 \ 256 \ 256
r3 = Abs(r1 - r2)
g3 = Abs(g1 - g2)
b3 = Abs(b1 - b2)
rs = Form1.VScrollRGB(0).Value
gs = Form1.VScrollRGB(1).Value
bs = Form1.VScrollRGB(2).Value
If r3 > rs Or g3 > gs Or b3 > bs Then
SetPixel Form1.Picture3.hdc, i, j, RGB(rs, gs, bs)
Else
SetPixel Form1.Picture3.hdc, i, j, RGB(0, 0, 0)
End If
Next
Next
---------------------------
Then I try to save the picture with this:
SavePicture Form1.Picture3.Image, "C:\outputpics\img" & count & ".bmp"
I just get a tan colored picture saved and not the picture displayed on
the form.