带有透明图片的PictureBox [英] PictureBox with Transparent Picture

查看:73
本文介绍了带有透明图片的PictureBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个有两个PictureBox的UserControl。

一个有想要显示给用户的图片,另一个有我用作叠加的图片。



叠加图片框使用具有透明背景的PNG图像。但是,每次运行UserControl时,叠加层都不会将PNG图像的透明部分显示为透明(显示为白色)。



我试过修改BackGroundColor和其他所有技巧都没关系,但没有任何工作。



任何人都可以帮助我吗?

解决方案

< blockquote>这个链接 [ ^ ]应该会有所帮助。它基本上是说从控件(在这种情况下是PictureBox)中驱逐一个新类并覆盖 OnPaintBackground 方法什么也不做。


是否将图片框不透明度属性更改为100%帮助?



我的坏。我以为你可以设置控件的不透明度。您只能对Form对象执行此操作。您必须进行自定义控件才能获得结果。


我不知道您在谈论哪种语言或IDE,但在Visual Basic编程时,没有像PictureBoxes的Opacity属性Studio 2008使用VB.NET或C#。


I'm working on a UserControl which has two PictureBoxes.
One has the picture I want to display to the user and the other has a picture that I use as an overlay.

The overlay PictureBox uses a PNG image with a transparent background. However, every time I run the UserControl, the overlay does not display the transparent parts of the PNG image as transparent (It appears white).

I've tried modifying the BackGroundColor and all other tricks up my sleeve but nothing is working.

Can anyone help me?

解决方案

This link[^] should be helpful. It basically says to derrive a new class from the control (PictureBox in this case) and override the OnPaintBackground method to do nothing.


Does changing the picturebox opacity property to something less 100% help?

My bad. I thought you could set the opacity for controls. You can only do that for Form objects. You will have to make a custom control to achieve your result.


I do not know which language or IDE you are talking about but there is nothing like an Opacity property for PictureBoxes when programming in Visual Studio 2008 using VB.NET or C#.


这篇关于带有透明图片的PictureBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆