|
-
August 2nd, 2001, 01:35 PM
#1
Remove everything but black......
How do i make it so that when someone clicks a button, it removes every color in a picturebox except for black?
--Ant
--------------------------------------------------
Want a javascript Editor? Visit:
http://members.fortunecity.com/ants12/jeditdload16.htm
Or email me:
[email protected]
-
August 3rd, 2001, 01:07 AM
#2
Re: Remove everything but black......
You can use the GetPixel API to determine what colo a pixel has, and the setpixel API to change it. However, this needs to check with every pixel, and can take some time with large pictures.
private Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (byval hdc as Long, byval x as Long, byval y as Long) as Long
private Declare Function SetPixel Lib "gdi32" Alias "SetPixel" (byval hdc as Long, byval x as Long, byval y as Long, byval crColor as Long) as Long
private Sub Command1_Click()
Picture1.ScaleMode = 3 ' pixel
for Y=1 to Picture1.ScaleHeight
for X=1 to Picture1.ScaleWidth
If GetPixel(Picture1.hDc, X, Y) <> 0 then
' not black, so set it red
SetPixel Picture1.hDc, X, Y, RGB(255,0,0)
End If
next X
next Y
End Sub
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
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
|