pascal - 无法获得 TBitmap 的透明颜色

标签 pascal lazarus freepascal

我有一个位图,我想在 TPaintBox 上绘制。问题是我之前必须将其旋转到特定角度。我决定使用 TBitmap32。 我这样做:我首先创建一个 TBitmap,然后将其传输到 TBitmap32,进行转换并再次将 TBitmap32 移动到 TBitmap。我正在 TPaintBox 上绘制最后一个 TBitmap。问题是我无法获得透明度。

位图有红色背景,我想将其设置为透明。你会帮忙吗?我做错了什么?

carImage32 := TBitmap32.Create;

carImage32.Width := carImageTMP.Width;
carImage32.Height := carImageTMP.Height;

carImage32.Canvas.Draw(0, 0, carImageTMP); //assign TBitmap

carImage := TBitmap.Create;
carImage.Width := carImageTMP.Width;
carImage.Height := carImageTMP.Height;


RotateBitmap(carImage32,angle,false,clNone,True);

carImage.Transparent:=True;
carImage.TransparentColor:=clRed;

carImage.Assign(carImage32);

paintBox.Canvas.Draw(0,0,carImage);

最佳答案

我解决了我的问题。 我也应该将这部分代码用于 TBitmap32:

auto.carImage32.DrawMode:=dmTransparent;
auto.carImage32.OuterColor:=clRed32;

并且工作了:)

关于pascal - 无法获得 TBitmap 的透明颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67039120/

相关文章:

delphi - 如何取消AssignCrt(Output)?

audio - 处理帕斯卡立体声

linux - 我无法在 Lazarus 中将 CGI 项目编译到 Linux

lazarus - 如何访问lazarus中的用户目录?

networking - 当 OnConnect 事件与 Lazarus 中另一个表单的 TTabControls 选项卡交互时,在 Indy10 上运行的服务器进程部分停止响应

delphi - 在 Delphi/FreePascal 中解析电子邮件时间戳

C语言。不使用空终止的字符串长度

ios - Xcode 5.0 安装命令行工具时出错

java - 处理 JPEG 元数据的最佳库是什么?

delphi - 有谁有一个关于如何使用 Synapse 的 Heartbeat 功能的好例子吗?