Getting rgb values

Anyone know how can I tell the RGB values of a pixel?  For example,
I want to run a test and show that pixel[5,7] of Timage is red 200, green 155, blue 240, and use showmessage to show these 3 values on the screen.
Using scanline below, I thought this would get the values with the Buffer defined as Pbytearray, and although this seems to return values, when I copy the image to the canvas as below shows (verifying that it copies the exact image to the canvas to prove that the scanline is getting the right colors), it doesn't look exactly like the Timage, as I was expecting. I've never used scanline before so I may be missing something but I thought this was how it worked.  Is there a better way to find out the individual rgb values?   I'm using D3.  
    for j:=0 to Image1.Picture.Height - 1 do

          for i:= 0 to Image1.Picture.Width - 1 do
               Canvas.Pixels[i,j] :=  rgb(Buffer[i+0],Buffer[i+1],Buffer[i+2]);
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.

Try changing this line:

Canvas.Pixels[i,j] :=  rgb(Buffer[i+0],Buffer[i+1],Buffer[i+2]);

To this:

Canvas.Pixels[i,j] :=  rgb(Buffer[i+2],Buffer[i+1],Buffer[i+0]);


Are you sure that the bitmap has the correct pixel format? Check Image1.Picture.Bitmap.PixelFormat before using the scanLine property. The pixelFormat must be 24bit, otherwise your code must look differently...

Then use this line:

Canvas.Pixels[i,j] :=  rgb(Buffer[i*3+0],Buffer[i*3+1],Buffer[i*3+2]);

or this one:

Canvas.Pixels[i,j] :=  rgb(Buffer[i*3+2],Buffer[i*3+1],Buffer[i*3+0]);

Regards, Madshi.

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
Its that old 'multiply by 3' again!
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

From novice to tech pro — start learning today.