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

≡放荡痞女 提交于 2019-12-05 00:45:39

问题


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). I am putting this on a form using TImage. I set TForm1.Color and the TForm1.TransparentColorValue to the same value and 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.

What am I doing wrong? I am using Delphi 2010 Trial.


回答1:


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.

  • Alpha Blended Splash Screen in Delphi - Part 1
  • Alpha Blended Splash Screen in Delphi - Part 2

Bye.




回答2:


Your settings are wrong. I am doing this (With a bitmap).

The TImage.Transparent should be false.

The Form.TransparentColourValue should be the colour of the part of The TImage that you want to be transparent.

The Form.TransparentColor should be True.

[Edit] It does not matter what colour the form is if the Image covers it completely



来源:https://stackoverflow.com/questions/1558420/how-can-i-make-a-form-transparent-according-to-a-png-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!