Bitmap.getpixel() Question

mBrannam

New member
Joined
Mar 30, 2011
Messages
4
Programming Experience
1-3
I have a bitmap named bmp that is 256x256 and contains all white pixels that were assigned by

VB.NET:
bmp.setpixel(x,y,color.white)


When I try to use a comparison to determine the color using:
VB.NET:
if bmp.getpixel(x,y) = color.white then
   label1.text = "success"
end if
, it never works properly.

However, if I use
VB.NET:
if bmp.getpixel(x,y).R = 255 then
   label1.text = "success"
end if
to get any pixel with a Red value of 255 (white included), the comparison succeeds.

What am I doing wrong with the first example?

I would like to get the first example working because the if statements get very long when I have to type

VB.NET:
if bmp.getpixel(x,y).R = 255 and bmp.getpixel(x,y).B = 0 and bmp.getpixel(x,y).G = 0 then
   label1.text = success
end if

to search for red.

Any help would be appreciated.
 
Last edited:
Back
Top