for i:=0 to 100 do
for j:=0 to 100 do
begin
if Image1.Canvas.Pixels[i,j]=RGB(100,100,100) then
begin
showmessage(IntToStr(i)+','+IntToStr(j));
end;
end;
这样一个循环语句,由于RGB值是100,100,100的有很多点,所以会不停的弹提示,我只想要找到第一个就行了,应该怎么写?谢谢!
for j:=0 to 100 do
begin
if Image1.Canvas.Pixels[i,j]=RGB(100,100,100) then
begin
showmessage(IntToStr(i)+','+IntToStr(j));
end;
end;
这样一个循环语句,由于RGB值是100,100,100的有很多点,所以会不停的弹提示,我只想要找到第一个就行了,应该怎么写?谢谢!
for j:=0 to 100 do
begin
if Image1.Canvas.Pixels[i,j]=RGB(100,100,100) then
begin
showmessage(IntToStr(i)+','+IntToStr(j));
exit; end;
end;
for j:=0 to 100 do
begin
if Image1.Canvas.Pixels[i,j]=RGB(100,100,100) then
begin
showmessage(IntToStr(i)+','+IntToStr(j));
exit; end;
end;
Break;//退出循环
exit;//退出过程
也可以用
tryfaillyend;
-------------------------
try
exceptend;
其实所谓的“退出”
就是不“执行”下面的代码,“跳出”过程的,我的那里不对了
难道必须是exit才行的吗
i,j: Integer;
label
_next;
begin
for i:=0 to 100 do
for j:=0 to 100 do
begin
if Image1.Canvas.Pixels[i,j]=RGB(100,100,100) then
begin
showmessage(IntToStr(i)+','+IntToStr(j));
goto _next
end;
end;_next:
showmessage('next')end;
for j:=0 to 100 do
begin
if Image1.Canvas.Pixels[i,j]=RGB(100,100,100) then
begin
showmessage(IntToStr(i)+','+IntToStr(j));
break;
end;
end;
比如这样:
k:=0;
for i:=0 to 100 do
begin
for j:=0 to 100 do
begin
if Image1.Canvas.Pixels[i,j]= RGB(100,100,100) then
begin
showmessage(IntToStr(i)+','+IntToStr(j));
inc(k);
break;
end; end;
if k>0 then
break;
end;