H
hug
Unregistered / Unconfirmed
GUEST, unregistred user!
我写了一下代码,为什么结果不一样?即gray和gray1不一样!请帮忙!
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
temp,emp : Tcolor;
gray,gray1 : Extended;
rr,rr1,gg1,bb1,gg,bb : byte;
p : pByteArray;
pp : integer;
begin
temp:= Image1.Canvas.Pixels[x,y];
rr := getRvalue(temp); {分解红色分量}
gg := getGvalue(temp); {分解绿色分量}
bb := getBvalue(temp); {分解蓝色分量}
Gray:= 0.3*rr+0.59*gg+0.11*bb;
p:=Image1.Picture.Bitmap.ScanLine[image1.Picture.Bitmap.Height-y-1];
emp:=p[x];
rr1 := getRvalue(emp); {分解红色分量}
gg1 := getGvalue(emp); {分解绿色分量}
bb1 := getBvalue(emp); {分解蓝色分量}
Gray1:= 0.3*rr1+0.59*gg1+0.11*bb1;
showmessage(floattostr(gray)+' '+floattostr(gray1));
edit1.Color:=temp;
edit2.Color:=emp;
end;
end.
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
temp,emp : Tcolor;
gray,gray1 : Extended;
rr,rr1,gg1,bb1,gg,bb : byte;
p : pByteArray;
pp : integer;
begin
temp:= Image1.Canvas.Pixels[x,y];
rr := getRvalue(temp); {分解红色分量}
gg := getGvalue(temp); {分解绿色分量}
bb := getBvalue(temp); {分解蓝色分量}
Gray:= 0.3*rr+0.59*gg+0.11*bb;
p:=Image1.Picture.Bitmap.ScanLine[image1.Picture.Bitmap.Height-y-1];
emp:=p[x];
rr1 := getRvalue(emp); {分解红色分量}
gg1 := getGvalue(emp); {分解绿色分量}
bb1 := getBvalue(emp); {分解蓝色分量}
Gray1:= 0.3*rr1+0.59*gg1+0.11*bb1;
showmessage(floattostr(gray)+' '+floattostr(gray1));
edit1.Color:=temp;
edit2.Color:=emp;
end;
end.