首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

-帮看下,为什么小弟我的读取图片像索点有有关问题?

2013-12-11 
--------------大虾帮看下,为什么我的读取图片像索点有问题?---------本帖最后由 cowbobe 于 2013-11-13 1

--------------大虾帮看下,为什么我的读取图片像索点有问题?---------
本帖最后由 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)

热点排行