469,106 Members | 2,099 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,106 developers. It's quick & easy.

SetPixel, Picturebox not saving correctly


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.

Jul 17 '05 #1
2 5603
Autoredraw True

On 16 Mar 2005 17:35:59 -0800, ti*****@gmail.com wrote:

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.


Jul 17 '05 #2
Tim
By golly it works!!!! Thanks for the one liner!!

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Pavan Arise | last post: by
reply views Thread by mark | last post: by
2 posts views Thread by Daniel | last post: by
2 posts views Thread by Ryan | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.