请问用 ScanLine 如何才能正确得到一张图片上某一个点的颜色。。。。。。。(50分)

Y

yqlqq

Unregistered / Unconfirmed
GUEST, unregistred user!
在一个Image中有一张 2 X 2 的图片,四个点的颜色分别是
  红 蓝
  白 黑
我用以下代码处理:

Image3.Picture.Bitmap.PixelFormat:=pf24bit;
for j := 0 to Image3.Picture.Bitmap.Height-1 do
begin
P := Image3.Picture.Bitmap.ScanLine[j];
S := '' ;
for i := 0 to Image3.Picture.Bitmap.Width-1 do
begin
S := S + ' ' + Format('%.2x', [P[j*3]]) + ' ' + Format('%.2x', [P[j*3 + 1]]) + ' ' + Format('%.2x', [P[j*3 + 2]]) ;
End ;
Memo1.Lines.Add(S) ;
End ;

运行后Memo1显示的结果是:

00 00 FF 00 00 FF
00 00 00 00 00 00

晕了,那怎么才能得到每一个点的颜色啊,是我的代码有错还是什么原因呢,请高手们指点指点,谢谢。。。。。。。。
 
24位图像,就是,3个点一个颜色

S := S + ' ' + Format('%.2x', [P[i*3]]) + ' ' + Format('%.2x', [P[i*3 + 1]]) + ' ' + Format('%.2x', [P[i*3 + 2]]) ;
用 I 值 ,J是行

哈哈,不晓得,你改了没得,上次回答是,明明是j呀,怎么现在你改成了,i了哟
 
Delphi Tcolor 定义为 $00 B G R
其中R,G,B都是字节。

procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
co : Tcolor;
r, g , b : Byte;
begin
x := Image1.Picture.Bitmap.Canvas.Pixels[X,Y];
r := Byte(x);
g := Byte(x shr 8);
b := Byte(x shr 16);
caption := InttoStr(x) + ', r='+inttostr(r)+ ', g='+inttostr(g)+ ', b='+inttostr(b);
end;
 
顶部