C++Builder 中的 Alpha 通道

问题描述

在 Borland/Embarcadero C++Builder 和 VCL 中,我试图开发一个带有图像的应用程序,其中一些部分(实际上是圆圈)随着时间的推移淡入或淡出。

我的代码主要如下:

void __fastcall TfmMain::FormCreate(TOBject *Sender)
{
    img = new TBitmap;
    img->Width = 800;
    img->Height = 600;
    fmMain->DoubleBuffered = true;
    ...
}

void __fastcall TfmMain::tmMainTimer(TObject *Sender)
{
    for(int i = 0; i < nbParts; i++){
        ...
        img->Brush->Color = clRed | alpha (t_time) << 24;
        //   alpha is a function returning 0 to 0xff,depending on required level of fade at time t_time) 
        img->Canvas->Ellipse(....);
    }
    fmMain->Canvas->Draw(0,img);
}

但结果完全不是我想要的:例如,应该淡出的部分的颜色在红色和黑色之间交替。应该淡入的部分也是如此。

我尝试了 DrawTransparent(),但出现错误:

DrawTransparent 不可访问

并且它具有整个位图的透明度值,而不是单个部分的透明度值。

我为每个部分尝试了一个单独的位图,但我可能有数百个,动画变得太慢了。

请有人帮忙,告诉我该怎么做吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...