Link to home
Start Free TrialLog in
Avatar of jexd99
jexd99

asked on

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
       begin
          Buffer:=Image1.Picture.Bitmap.ScanLine[j];

          for i:= 0 to Image1.Picture.Width - 1 do
            begin
               Canvas.Pixels[i,j] :=  rgb(Buffer[i+0],Buffer[i+1],Buffer[i+2]);
            end;
       end;
Avatar of rwilson032697
rwilson032697

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]);

Cheers,

Raymond.
ASKER CERTIFIED SOLUTION
Avatar of Madshi
Madshi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Its that old 'multiply by 3' again!