供参考: 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;
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;