472,119 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

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 5704
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
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.