I'm looking for a way to get the color of a particular pixel in a TImage. I
want to get the hex-format (like $00DBE0E3). Does anyone know how to do
that?
Thanks a lot,
Bert Prins
>Hello.
>
>I'm looking for a way to get the color of a particular pixel in a TImage. I
>want to get the hex-format (like $00DBE0E3). Does anyone know how to do
>that?
procedure TForm1.Button1Click(Sender: TObject);
Var
C :TColor;
begin
C := Image1.Canvas.Pixels[ 1, 1 ];
ShowMessage( IntToHex( C, 8 ) );
end;
> Hello.
Hi.
If you want it in RGB format you will need something like this:
<code style="dirty" class="should_work">
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
c:TColor;
begin
c:=Image1.Canvas.Pixels[x,y];
c:=((c and $000000FF) shl 16) or
((c and $00FF0000) shr 16) or
(c and $0000FF00);
label1.Caption:='$'+IntToHex(i,8);
end;
</code>
This will work probably only for BMP's (if not changed) but it
shouldn't be problem, right?
Grtz,
Andrzej
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/