Graphics::TBitmap*pBitmap=new Graphics::TBitmap();
try
{pBitmap->LoadFromFile("Plane.bmp");
//调入位图
pBitmap->Transparent = true;
//设置透明属性
pBitmap->TransparentColor=
pBitmap->Canvas->Pixels[2][2];
//从位图上取得要设置成的
透明颜色,也可以直接给出
Form1->Canvas->Draw(10,20,pBitmap);
//AA
//在窗体上显示透明位图,
没有设置TransparentMode
//以位图[2][2]处的像素的颜色为透明色
pBitmap->TransparentMode = tmAuto;
//设置透明模式, tmAuto:
TransparentColor属性返回位
//图最左下角像素的颜色,作为透明色;
//tmFixed: TransparentColor属性返回位图
上某一像素的颜色,作为透明色。
Form1->Canvas->Draw(10,100,pBitmap);
//BB
//在窗体上显示透明位图,
与AA行有所不同
//以位图最左下角的像素的颜色为透明色
Image1->Canvas->Draw(30,20,pBitmap);
//在背景位图上显示透明位图
}
catch (...)
{
ShowMessage("不能调入或显示位图!");
//显示出错信息
}
delete pBitmap; //删除对像
try
{pBitmap->LoadFromFile("Plane.bmp");
//调入位图
pBitmap->Transparent = true;
//设置透明属性
pBitmap->TransparentColor=
pBitmap->Canvas->Pixels[2][2];
//从位图上取得要设置成的
透明颜色,也可以直接给出
Form1->Canvas->Draw(10,20,pBitmap);
//AA
//在窗体上显示透明位图,
没有设置TransparentMode
//以位图[2][2]处的像素的颜色为透明色
pBitmap->TransparentMode = tmAuto;
//设置透明模式, tmAuto:
TransparentColor属性返回位
//图最左下角像素的颜色,作为透明色;
//tmFixed: TransparentColor属性返回位图
上某一像素的颜色,作为透明色。
Form1->Canvas->Draw(10,100,pBitmap);
//BB
//在窗体上显示透明位图,
与AA行有所不同
//以位图最左下角的像素的颜色为透明色
Image1->Canvas->Draw(30,20,pBitmap);
//在背景位图上显示透明位图
}
catch (...)
{
ShowMessage("不能调入或显示位图!");
//显示出错信息
}
delete pBitmap; //删除对像
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货