procedure TBitmap8_FilterPixels1(_SrcBmp, _DstBmp: TBitmap; _Callback: TPixel8FilterCallback);
const
BytesPerPixel = 1;
var
x: Integer;
y: Integer;
w: Integer;
h: Integer;
SrcLine: PByte;
DstLine: PByte;
SrcPixel: PByte;
DstPixel: PByte;
BytesPerLine: Integer;
begin
_SrcBmp.PixelFormat := pf8bit;
w := _SrcBmp.Width;
h := _SrcBmp.Height;
_DstBmp.Assign(
nil);
_DstBmp.PixelFormat := pf8bit;
_DstBmp.Palette := MakeGrayPalette;
TBitmap_SetSize(_DstBmp, w, h);
if (h = 0)
or (w = 0)
then
Exit;
//==>
BytesPerLine := ((w * 8 * BytesPerPixel + 31)
and not 31)
div 8;
SrcLine := _SrcBmp.ScanLine[0];
DstLine := _DstBmp.ScanLine[0];
for y := 0
to h - 1
do begin
SrcPixel := SrcLine;
DstPixel := DstLine;
for x := 0
to w - 1
do begin
DstPixel^ := SrcPixel^;
_Callback(x, y, DstPixel^);
Inc(SrcPixel, BytesPerPixel);
Inc(DstPixel, BytesPerPixel);
end;
Dec(SrcLine, BytesPerLine);
Dec(DstLine, BytesPerLine);
end;
end;
procedure TBitmap8_FilterPixels2(_SrcBmp, _DstBmp: TBitmap; _Callback: TPixel8FilterCallback);
const
BytesPerPixel = 1;
var
x: Integer;
y: Integer;
w: Integer;
h: Integer;
DstLine: PByte;
DstPixel: PByte;
BytesPerLine: Integer;
begin
_SrcBmp.PixelFormat := pf8bit;
w := _SrcBmp.Width;
h := _SrcBmp.Height;
_DstBmp.Assign(_SrcBmp);
if (h = 0)
or (w = 0)
then
Exit;
//==>
BytesPerLine := ((w * 8 * BytesPerPixel + 31)
and not 31)
div 8;
DstLine := _DstBmp.ScanLine[0];
for y := 0
to h - 1
do begin
DstPixel := DstLine;
for x := 0
to w - 1
do begin
_Callback(x, y, DstPixel^);
Inc(DstPixel, BytesPerPixel);
end;
Dec(DstLine, BytesPerLine);
end;
end;
procedure TBitmap8_FilterPixels3(_SrcBmp, _DstBmp: TBitmap; _Callback: TPixel8FilterCallback);
const
BytesPerPixel = 1;
var
x: Integer;
y: Integer;
w: Integer;
h: Integer;
SrcBuffer: PByte;
DstBuffer: PByte;
DstLine: PByte;
DstPixel: PByte;
BytesPerLine: Integer;
begin
_SrcBmp.PixelFormat := pf8bit;
w := _SrcBmp.Width;
h := _SrcBmp.Height;
_DstBmp.Assign(
nil);
_DstBmp.PixelFormat := pf8bit;
_DstBmp.Palette := MakeGrayPalette;
TBitmap_SetSize(_DstBmp, w, h);
if (h = 0)
or (w = 0)
then
Exit;
//==>
BytesPerLine := ((w * 8 * BytesPerPixel + 31)
and not 31)
div 8;
SrcBuffer := _SrcBmp.ScanLine[h - 1];
DstBuffer := _DstBmp.ScanLine[h - 1];
Move(SrcBuffer^, DstBuffer^, BytesPerLine * h);
DstLine := AddToPtr(DstBuffer, BytesPerLine * (h - 1));
for y := 0
to h - 1
do begin
DstPixel := DstLine;
for x := 0
to w - 1
do begin
_Callback(x, y, DstPixel^);
Inc(DstPixel, BytesPerPixel);
end;
Dec(DstLine, BytesPerLine);
end;
end;