有张位图格式是 pf1bit . 我想扫描整张图片,根据每个像素的值来判断下一步该怎么做. 我编的程序老出错特求代码谢谢

解决方案 »

  1.   

    供参考:
      procedure GetPixel(Pixel: Byte; Count: Integer);
      var
        I: Integer;
        v: Byte;
      begin
        v := $80;
        for I := 1 to Count do
        begin
          if (Pixel and v) = 0 then
            // 黑,写你的代码
          else
            // 白,写你的代码
          v := v shr 1;
        end;
      end;var
      x, y: Integer;
      Width, Surplus: Integer;
      p: pByte;
    //  Bmp: TBitmap;  // 你的图像
    begin
      Surplus := Bmp.Width and 7;
      Width := Bmp.Width shr 3;
      for y := 0 to Bmp.Height - 1 do
      begin
        p := Bmp.ScanLine[y];
        for x := 0 to Width - 1 do
        begin
          GetPixel(p^, 8);
          Inc(p);
        end;
        if Surplus > 0 then
          GetPixel(p^, Surplus);
      end;
    end;