Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Get color of particular pixel

36 views
Skip to first unread message

Bert Prins

unread,
Dec 23, 2003, 10:00:56 AM12/23/03
to
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?

Thanks a lot,

Bert Prins


J French

unread,
Dec 23, 2003, 10:34:36 AM12/23/03
to
On Tue, 23 Dec 2003 16:00:56 +0100, "Bert Prins"
<prin...@hotmail.com> wrote:

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

Andrzej Szukiewicz

unread,
Feb 29, 2004, 6:19:48 PM2/29/04
to
On Tue, 23 Dec 2003 16:00:56 +0100, Bert Prins <prin...@hotmail.com>
wrote:

> 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/

0 new messages