本文提供一种使用 Graphics::TBitmap 的方法使位图背景透明化,直接上代码:

Graphics::TBitmap *bm = new Graphics::TBitmap;
bm->Transparent = true;
bm->TransparentMode = tmFixed;
bm->TransparentColor = clWhite;
MForm->ImageList1->GetBitmap(2, bm);
this->Canvas->Draw(10, 100, bm);
delete bm;

TransparentMode:设置透明模式 tmAuto:使用图片左下角像素的颜色作为透明颜色 tmFixed:使用 TransparentColor 属性指定的颜色作为透明颜色