Comparing Colors


colors can be cast to int32 and compared exactly like integers


Dim p As New picture(100,100,32)

Dim surf As RGBSurface = p.RGBSurface

Dim nx, ny As Integer

If Int32(surf.Pixel( nx, ny)) >= Int32(&c00000000) And Int32(surf.Pixel( nx, ny)) <= Int32(&c03030300) Then
End If

Thanks Norman!

That is a much more better way and far more elegant too!

Another question.
How/where can I find out what values start becoming black? The values chosen were by accident. They work most of the time, but not all. In some cases there are reds that mix into the black lines, levels of gray too. So I need to find a value that will work in 99% or the cases.

What I am trying to do is to make the object in orange, the same size as the surrounding grid. In the picture showing R126, it has been auto moved to the top and the left of the grid surrounding it. However when it goes to expanding it to the right, it goes off screen, which makes no sense to me other than the color of the right vertical grid line is something outside of the selected colors.

Any ideas would be appreciated!
Thank you,

Is this a background of some sort that you put object on top of and then resize to fill the “slot” so to speak ?

If that original image has anti aliased line then you will et the nixing of colors you mention
And if the line is thin enough you may not get any black pixel - just ones that are from the anti aliasing and so are a mix of red/black

Is the background color solid red ? (one consistent color ?)
if so then watch for when the pixel IS NOT that solid color might be all you need to watch for since that could be the anti-aliasing edge etc

Hi Norman,

Yes, I put objects over top of the background picture.

The colors vary, and the red’s are not all the same reds either. There’s also some spaces that have gray colors too.

This is why I was asking if there is a way to find out the color value of the blacks and red/black etc so I can formulate a decent range. In the end, the colors would be programmable but for the moment, just finding out how to improve this.

Thanks again,

you “might” be able to determine a range of “blacks” by comparing the Red, Green and Blue components… and if they are all less that some value (maybe 24?) that might be considered

I would rather go with the HSV color model. Everything that’s “starting to become black” can be expected to have rather low brightness and high saturation values.