请问怎么把一个图片中一个一个的像素的值取出来?
我是这么做的
for i:=1 to wBitMap.Height do
    begin
      for j:=1 to wBitMap.Width do
      begin
        intPix:= integer(wBitMap.Canvas.Pixels[i,j]);      
      end;
    end;但是显示出来的数值好象不大对啊,这样是遍历整个图片吗?

解决方案 »

  1.   

    应该就是这样的,用RGB转一下就成了
      

  2.   

    用这三个API:GetRValue, GetGValue, GetBValue,具体的看帮助。
    ------------------------------------------------------------
        The GetRValue macro retrieves an intensity value for the red component of a 32-bit red, green, blue (RGB) value. BYTE GetRValue(
        DWORD rgb // 32-bit RGB value 
       );
      

  3.   

    要看你是什么图像格式了
    每一种图像格式都有自己的存贮的方法
    在image中显示的图像和实际的图像之间有个换算比例的问题,建议不要从canvas中取
    除非是自己在canvas中画的图像
      

  4.   

    image中显示的图像和实际的图像之间有个换算比例的问题?
    这个倒没注意过,我只想把每个像素的信息取出来
      

  5.   

    procedure TForm1.Button1Click(Sender: TObject);// This example shows drawing directly to the BitMap
    var
      x,y : Integer;
      BitMap : TBitMap;
      P : PByteArray;
    begin
      BitMap := TBitMap.create;
      try
        // On Windows replace MyBitmap.png with a full pathname such as
        // C:\Program Files\Common Files\Borland Shared\Images\Splash\256color\factory.bmp
        BitMap.LoadFromFile('MyBitmap.png');
        for y := 0 to BitMap.Height -1 do
        begin
          P := BitMap.ScanLine[y];      for x := 0 to BitMap.Width -1 do
            P[x] := y;
        end;
        Canvas.Draw(0,0,BitMap);
      finally
        BitMap.Free;
      end;
    end;
      

  6.   

    用Scanline,速度会快上N倍。
    而且,具体的实现还与位图的格式有关,24位与8位,是不一样的。
      

  7.   

    怎么可以把整个图像每一个像素放在同一个地方:intPix:= integer(wBitMap.Canvas.Pixels[i,j]);
      

  8.   

    你可以直接用
     intPix:= Canvas.Pixels[i,j]
    来取得图像的一个像素.