我有一幅图的背景是白色的,我想用BitBlt()将它帖到另一幅图上,并使它的白色背景透明,如何做呢?谢谢。
解决方案 »
- 赚分帖~~~
- 使用agentobject_tlb.pas文件的问题.
- 初识delphi,请问一个最简单的问题!
- 在线等,100分,立结TListBox滚动问题!
- 在delphi 中可不可以用BCP
- 怎样用ADO读取BLOB信息?在线等待!
- 关于字符串常量的长度问题
- 为什么我用ShowMessage(FormatDatetime('yyyy-mm/dd',date)) 得到的是'2002-07-23' ?
- 老问题,有没有新的答案?关于dbgrid中回车键代替tab键的问题。
- 从装数据库系统的情况下,如何恢复数据库?
- 给分怎么给啊?我怎么最多只能给26分啊?我想多给点分不行吗?
- Form上有许多矩形区域,要使鼠标移到这些区域内时就beep,应该怎么做?
b1, b2: TBitmap;
begin
b1 := TBitmap.create;
b2 := TBitmap.create;
b1.loadfromfile('d:\1.bmp');
b2.loadfromfile('d:\2.bmp');
b2.Transparent := true;
b2.TransparentColor := clWhite; // 或 b2.canvas.pixels[0, 0];等
b1.canvas.Draw(0, 0, b2);
canvas.Draw(0, 0, b1);
b1.free;
b2.free;
end;
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;type
TForm1 = class(TForm)
Image1: TImage;
Image2: TImage;
Button1: TButton;
Image3: TImage;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
b1,b2,b3,b4,b5,b6:tbitmap;
trcolor:tcolor;
oldcol:longint;
implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
begin
trcolor:=clwhite;
b1:=Tbitmap.Create;
b2:=Tbitmap.Create;
b3:=Tbitmap.Create;
b4:=Tbitmap.Create;
b5:=Tbitmap.Create;
b6:=Tbitmap.Create;
b1:=image1.Picture.Bitmap;
b2:=image2.Picture.Bitmap;
b3.Width:=b1.Width;
b3.Height:=b1.Height;
b3.Monochrome:=true;
b4.Width:=b1.Width;
b4.Height:=b1.Height;
b4.Monochrome:=true;
b5.Width:=b1.Width;
b5.Height:=b1.Height;
b6.Width:=b1.Width;
b6.Height:=b1.Height;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
oldcol:=setbkcolor(b2.Canvas.Handle,colortorgb(trcolor));
bitblt(b3.Canvas.Handle,0,0,b3.Width,b3.Height,b2.Canvas.Handle,0,0,srccopy);
setbkcolor(b2.Canvas.Handle,oldcol);
bitblt(b4.Canvas.Handle,0,0,b4.Width,b4.Height,b3.Canvas.Handle,0,0,notsrccopy);
bitblt(b5.Canvas.Handle,0,0,b5.Width,b5.Height,b2.Canvas.Handle,0,0,srccopy);
bitblt(b5.Canvas.Handle,0,0,b5.Width,b5.Height,b4.Canvas.Handle,0,0,srcand);
bitblt(b6.Canvas.Handle,0,0,b6.Width,b6.Height,b1.Canvas.Handle,0,0,srccopy);
bitblt(b6.Canvas.Handle,0,0,b6.Width,b6.Height,b3.Canvas.Handle,0,0,srcand);
bitblt(b6.Canvas.Handle,0,0,b6.Width,b6.Height,b5.Canvas.Handle,0,0,srcinvert);
image3.Picture.Bitmap:=b6;
image3.Refresh;
end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
b1.Free;
b2.Free;
b3.Free;
b4.Free;
b5.Free;
b6.Free;
end;end.