We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

TColor and how to get Colour Range

westy100697
westy100697 asked
on
Medium Priority
849 Views
Last Modified: 2006-11-17
My question is as follows....

 I am writing a program for a sports medicine practice. It involoves importing an avi made using a video capture device. Now when I import the image into delphi I have options on a TImage to change the number of colours ie 32bit, 16bit  etc. My question involves the actual colours themselves and how they are listed in the 16million colour format. For example ... if the image has a person in it an on that person there are yellow markers as I perceive it.
Now to pick out all the colours on that yellow maker for instance may require me to check the range (converted from Hex) of 4,000,000 to 16,000,000 . Is there a definite scale of Yellow, Blue, Red etc that will not miss out any colours as in delphi3 help i can only see the absolute colours listed for example white is $00FFFFFF and black is
$00000000 . Now yellow will vary based on intensity and i guess that is my question how can you list/get the colurs
in a range based on their intensity ie from least intense to most intense but not moving out of the actual colours range. I use Canvas.Pixels[x,y] to get the pixel colour. Can anyone help me?

Thanks in advance
Westy
Comment
Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
So using the pixels property of the canvas you are given a longint value so how can you tell exactly what colour has been chosen if as you say it is in BGR format instead of RGB format if you see what i mean because when you convert back to hex you won't know what order it is in or will you. Is there some way of telling this?
Sure is.

The Pixels property returns a TColor which is a longint with the low order 3 bytes containing BGR channels, 8 bits per channel. So to get each channel do this:

Blue = (Pixels[x, y] AND $FF0000) SHR 16
Green = (Pixels[x, y] AND $00FF00) SHR 8
Red =  Pixels[x, y] AND $0000FF

The pixels property is not very fast so if performance becomes an issue you may want to access the memory directly.

Author

Commented:
Thanks very muchly appreciate the input and here are the points .

Westy 8-)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.