PictureBox中的透明背景 [英] Transparent background in PictureBox

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

问题描述

您好。

在Form上我只有面板,每个PicterBox动态创建。

我在面板上加载图像,并为每个图像创建新的Picterbox。

我可以移动这个PicterBoxes,但当一个PicterBox穿过另一个时,它会丢失图像透明背景。我知道,因为所有的PicterBox都有Panel作为Parent。

我收到了这个

< img src =''http:// rghost。 ru / 46169807 / image.png''/>

但想要这个

< img src =''http://rghost.ru/46169920/image.png''/>

对此有何帮助?

Hi.
On Form i have only panel, every PicterBox creates dynamically.
I load images on panel, and create new Picterbox for every image.
I can move this PicterBoxes, but when one PicterBox cross another, it loses Images transparent background. I know, that it''s becouse all PicterBoxes has Panel as Parent.
I got this
<img src=''http://rghost.ru/46169807/image.png'' />
but want this
<img src=''http://rghost.ru/46169920/image.png'' />
Any help with this?

推荐答案

在屏幕上,没有透明度这样的东西。这是一个比喻意味着你可以通过另一个看到一个图像。因此,有时解决方案定义了您想要看到的内容。



使用支持透明度的PNG图像。确保实际使用透明度功能。我不知道你用过什么,但是可以做到的好工具之一就是开源GIMP:

http://en.wikipedia.org/wiki/GIMP [ ^ ],

http://www.gimp.org/ [ ^ ]。



不要使用 PictireBox 。通过覆盖其 OnPaint 方法或处理事件 Paint ,直接在某些控件上呈现两个位图。使用其中一种方法 System.Drawing.Graphics.DrawImage

http://msdn.microsoft.com/en-us/library/system.drawing.graphics.aspx [ ^ ]。



详情请见我过去的答案:



如何从旧图纸中清除面板 [ ^ ],

在C#中绘制一个矩形 [ ^ ],

在图片框中附加图片 [ ^ ];



在mdi子表单之间绘制线条 [ ^ ],

捕获面板上的图纸 [ ^ ],

什么样的俏皮方法是油漆? (DataGridViewImageCell.Paint(...)) [ ^ ],

如何加速我的vb.net应用程序? [ ^ ]。



-SA
On a screen, there is no such thing as "transparency". This is a metaphor meaning that you can see one image through another one. So, sometimes the solutions defines what do you want to see.

Use PNG images supporting transparency. Make sure transparency feature is actually used. I don''t know what did you used, but one of good tools which can do it is, for example, open-source GIMP:
http://en.wikipedia.org/wiki/GIMP[^],
http://www.gimp.org/[^].

Don''t use PictireBox. Directly render two bitmaps on some control, by overriding its OnPaint method or handling the event Paint. Use one of the methods System.Drawing.Graphics.DrawImage:
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.aspx[^].

For further detail, please see my past answers:

How do I clear a panel from old drawing[^],
draw a rectangle in C#[^],
Append a picture within picturebox[^];

Drawing Lines between mdi child forms[^],
capture the drawing on a panel[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
How to speed up my vb.net application?[^].

—SA


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

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