C
cqbaobao
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TFrmCapture.fs(cdfB, cdfG, cdfR: integer);
const
fsUnit = 2;
var
i, j, m: integer;
p1, p: PByteArray;
w, h: integer;
begin
w := bmpCap.Width;
h := bmpCap.Height;
bmpFspz.Assign(bmpCap);
// 腐蚀
for i := 0 to h - 1 do
begin
p1 := bmpCap.ScanLine;
p := bmpFspz.ScanLine;
j := 3;
while j < (w - 1) * 3 do
begin
// 1 * 3 腐蚀, 预先置为白色,待挖去
p[j] := 255;
p[j + 1] := 255;
p[j + 2] := 255;
for m := -1 to fsUint - 1 do
if (abs(p1[j + m * 3] - colBakB) > cdfB) or
(abs(p1[j + m * 3 + 1] - colBakG) > cdfG) or
(abs(p1[j + m * 3 + 2] - colBakR) > cdfR) then
begin
// 置为黑色,留下
p[j] := 0;
p[j + 1] := 0;
p[j + 2] := 0;
break;
end;
inc(j, 3);
end;
end;
end;
bmpCap的底色为蓝色,24位图,以上代码对bmpCap进行腐蚀,
colBakB,colBakG,colBakR为背景某点颜色三个分量,
cdfB,cdfG,cdfR它们的值如何给,蓝色的背景是否对cdfB要大一点呢?
const
fsUnit = 2;
var
i, j, m: integer;
p1, p: PByteArray;
w, h: integer;
begin
w := bmpCap.Width;
h := bmpCap.Height;
bmpFspz.Assign(bmpCap);
// 腐蚀
for i := 0 to h - 1 do
begin
p1 := bmpCap.ScanLine;
p := bmpFspz.ScanLine;
j := 3;
while j < (w - 1) * 3 do
begin
// 1 * 3 腐蚀, 预先置为白色,待挖去
p[j] := 255;
p[j + 1] := 255;
p[j + 2] := 255;
for m := -1 to fsUint - 1 do
if (abs(p1[j + m * 3] - colBakB) > cdfB) or
(abs(p1[j + m * 3 + 1] - colBakG) > cdfG) or
(abs(p1[j + m * 3 + 2] - colBakR) > cdfR) then
begin
// 置为黑色,留下
p[j] := 0;
p[j + 1] := 0;
p[j + 2] := 0;
break;
end;
inc(j, 3);
end;
end;
end;
bmpCap的底色为蓝色,24位图,以上代码对bmpCap进行腐蚀,
colBakB,colBakG,colBakR为背景某点颜色三个分量,
cdfB,cdfG,cdfR它们的值如何给,蓝色的背景是否对cdfB要大一点呢?