怎样对两幅图象进行异或处理!(10分)

C

cjh_xf

Unregistered / Unconfirmed
GUEST, unregistred user!
想要对两幅图象进行异或处理。我的图象是黑底红字(或绿字的),想要把两幅图象中的字保存下来放到一副图中去。
 
//将两副BMP图象进行异或操作
procedure TForm1.Button3Click(Sender: TObject);
var
Bmp1, Bmp2: TBitmap;
begin
Bmp1 :=TBitmap.Create;
Bmp1.Assign(Image1.Picture.Bitmap);
Bmp2 :=TBitmap.Create;
Bmp2.Assign(Image1.Picture.Bitmap);
BitBlt(Bmp2.Canvas.Handle,0,0,Bmp2.Width,Bmp2.Height,Bmp1.Canvas.Handle,0,0,SRCINVERT);
Image2.Picture.Bitmap.Assign(Bmp1);
Bmp1.Free;
Bmp2.Free;
end;
 
procedure TForm1.Button2Click(Sender: TObject);
var
l1, l2, l3: PByteArray;
y, x: integer;
b: boolean;
Bmp1, Bmp2, Bmp3: TBitmap;
begin

Bmp1 :=TBitmap.Create;
Bmp1.Assign(Image1.Picture.Bitmap);
Bmp2 :=TBitmap.Create;
Bmp2.Assign(Image2.Picture.Bitmap);
Bmp3 :=TBitmap.Create;
Bmp3.Width := Bmp1.Width;
Bmp3.Height := Bmp1.Height;

Bmp1.pixelformat := pf32bit;
Bmp2.pixelformat := pf32bit;
Bmp3.pixelformat := pf32bit;

for y := 0 to Image1.Picture.Height-1 do
begin
l1 := Bmp1.ScanLine[y];
l2 := Bmp2.ScanLine[y];
l3 := Bmp3.ScanLine[y];
b := false;
for x := 0 to Image2.Picture.Width-1 do
begin
if l1[x]<>l2[x] then
begin
l3[x] := l1[x] and l2[x];
end
else l3[x] := l1[x];
end;
end;

Image2.Picture.Bitmap.Assign(Bmp3);
Bmp1.Free;
Bmp2.Free;
Bmp3.Free;

end;
 
我要处理的两幅图是相同的底色但不同的图象,我想让两幅图中的图象合并到一副图中显示。两位的方法似乎都不行[:(]
敬请关注!分不多了,提出问题大家探讨探讨,如要分,等我聚了给![:)]
 
你把上面的ScanLine方法稍改一下可能就能满足要求。
另外,你的图片是什么格式的?
 
多人接受答案了。
 
顶部