简体   繁体   English

如何根据PNG图像使表单透明?

[英]How can I make a form transparent according to a PNG image?

I have a PNG image that uses transparency (it is actually a circle with gradient effect from black in the middle, to transparent on the margins). 我有一个使用透明性的PNG图像(实际上是一个渐变效果的圆圈,从中间的黑色到边缘的透明度都是透明的)。 I am putting this on a form using TImage . 我正在使用TImage将其放在表单上。 I set TForm1.Color and the TForm1.TransparentColorValue to the same value and TForm1.TransparentColor:=true . 我将TForm1.ColorTForm1.TransparentColorValue设置为相同的值,并将TForm1.TransparentColor:=true设置为相同的值。

Now, when I run the program the gradient part of the image is displayed with the color of the form. 现在,当我运行程序时,图像的渐变部分将以表格的颜色显示。 What I am looking for is to enable the transparency of the PNG image using the transparent form effect. 我正在寻找的是使用透明形式效果启用PNG图像的透明性。

What am I doing wrong? 我究竟做错了什么? I am using Delphi 2010 Trial. 我正在使用Delphi 2010试用版。

I suspect you're trying to create something like a transparent splashscreen , if that's the case, you can read these great articles, they describes a nice way to use a transparent png in a delphi form. 我怀疑您正在尝试创建透明的启动画面之类的东西,如果是这样的话,您可以阅读这些精彩的文章,它们描述了一种以delphi形式使用透明png的好方法。

Bye. 再见

Your settings are wrong. 您的设置错误。 I am doing this (With a bitmap). 我正在这样做(使用位图)。

The TImage.Transparent should be false. TImage.Transparent应该为false。

The Form.TransparentColourValue should be the colour of the part of The TImage that you want to be transparent. Form.TransparentColourValue应该是要透明的TImage部分的颜色。

The Form.TransparentColor should be True. Form.TransparentColor应该为True。

[Edit] It does not matter what colour the form is if the Image covers it completely [编辑]图像完全覆盖窗体的颜色并不重要

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM