读书人

-帮看下,为什么小弟我的读取图片像索点

发布时间: 2013-12-11 16:44:13 作者: rapoo

--------------大虾帮看下,为什么我的读取图片像索点有问题?---------
本帖最后由 cowbobe 于 2013-11-13 18:50:06 编辑 整了几天了,偶要实现的功能是这样的:

把一个BMP图片所有像素点存到一个数组中

但为什么会报错?如何改?谢...


//自定义结构

type

TPointNote=record
X:Integer;
Y:Integer;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
i,x,y:Integer;
PointNote:Array of TPointNote;
P : PByteArray;
begin

SetLength(PointNote,0); //先设0
x:=0;

for y := 0 to image1.Picture.Bitmap.Height -1 do
begin
P := image1.Picture.Bitmap.ScanLine[y];
for x := 0 to image1.Picture.Bitmap.Width -1 do
begin
if p[x]=clRed then//如果像素点是红色,则记录下来
begin
Inc(i);//数组递增1
SetLength(PointNote,x);//动态设置数据长度
PointNote[i].x:=x;
PointNote[i].y:=y;
end;
next;
end;
next;
end;

Image1.Refresh;

end;

[解决办法]
两个字:笔误
Line28:Setlength(PointNote,I)

读书人网 >.NET

热点推荐