unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
Button1: TButton;
Memo1: TMemo;
Memo2: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
newbitmap:tbitmap;
i,j,k:integer;
begin
newbitmap:=tbitmap.Create;
newbitmap.Width:=image1.Width;
newbitmap.Height:=image1.Height;
newbitmap.Assign(image1.Picture.Bitmap);
for j:=0 to image1.Height-1 do
begin
if (newbitmap.Canvas.Pixels[0,j]=rgb(0,0,0)) then
memo1.Lines.Add(format('%d,%d',[0,j]));
for i:=0 to image1.Width-1 do
begin
if (newbitmap.Canvas.Pixels[i,j-1]=0) and (newbitmap.Canvas.Pixels[i,j+1]=0)and(newbitmap.Canvas.Pixels[i,j-2]=0)and
(newbitmap.Canvas.Pixels[i,j+2]=0)and (newbitmap.Canvas.Pixels[i-1,j-1]=0)and
(newbitmap.Canvas.Pixels[i+1,j-1]=0)then
memo2.Lines.Add(format('%d,%d',[i,j]));
end;
end;
end;
end.运行出来结果:
Memo1
0,19
0,40
0,62
0,83
0,105
0,126
Memo2
159,18
17,19
18,19
159,19
54,40
55,40
56,40
201,40
202,40
203,40
86,84
87,84
134,125
135,125 请问以下,怎么才能让memo2中只输出象素点象近的一个点呢~~~(图片已上传)