Check image for rgb

What's the best and *fastest* way to check an image for a certain rgb color?  If it contains that color, how can I get the X,Y of where the color is in the image?
Grant FullenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mokuleCommented:
You need to use scanline which gives You an address of image row bytes array.
The index to scanline gives You Y, and the index to fthe bytes array gives You X.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JohnjcesCommented:
You might try: (not tested)...

type
  TRGBArray = array[0..32767] of TRGBTriple;
  PRGBArray = ^TRGBArray;

var
 MyRed, MyGrn, MyBlu : Integer;
 X, Y : Integer;
  Row: PRGBArray;
begin
 Bmp.PixelFormat := pf24Bit;
 {Y is the pixel row of the pixel you want}
 Row := Bmp.ScanLine[Y];
 {X is the position in the row or column or the pixel}
 MyRed := Row[x].rgbtRed;
 MyGrn := Row[x].rgbtGreen;
 MyBlu := Row[x].rgbtBlue;
end;

This is not tested, off the top of my head, sort of, but might get you started.

I believe that you can add the results and get you RGB color of that pixel.

John
0
mokuleCommented:
Bmp.PixelFormat := pf24Bit;
This is not a good option to change bitmap format.
The rest of code should rather depend on on Bmp.PixelFormat value

In the case of pf24Bit should be
 MyRed := Row[3*x+2].rgbtRed;
 MyGrn := Row[3*x+1].rgbtGreen;
 MyBlu := Row[3*x].rgbtBlue;
0
mokuleCommented:
Hehe TRGBTriple. My comment is not valid in the second part
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.