VB.NET Winforms:覆盖两个透明图像 [英] VB.NET Winforms: Overlay two transparent images

查看:50
本文介绍了VB.NET Winforms:覆盖两个透明图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在winform中叠加两个透明图像,但是它始终将窗体的背景图像呈现在顶部透明图像的后面,而不是第二个图像...

I am attempting to overlay two transparent images within a winform, but it keeps rendering the form's background image behind the top transparent image, as opposed to the second image...

我的基本设置是我有两个面板,每个面板中都有一个画框.图片框中的每个图像都有一些透明区域.我已经将面板的BackColor设置为color.transparent.

My basic set up is I have two panels and in each panel is a picturebox. Each image in the picture boxes have some transparent areas. I've set the BackColor of the panels to color.transparent.

当我将一个面板覆盖另一个面板时,我看到表单的背景色与底图相反.

When I make one panel overlay the other I'm seeing the form's backcolor come through as opposed to the underlaying image.

我缺少可以设置的属性吗?

Am I missing a property that I can set?

推荐答案

您只需要一个图片框.可以使用图形完成覆盖.

You only need one picture box. The overlay can be done with graphics.

Imports System.Drawing

Dim OverlayImage As New Bitmap("Some Path", True)
Dim BackImage As New Bitmap("Some Path", True)
g As Graphics = Graphics.FromImage(BackImage)

g.DrawImage(OverlayImage, 0, 0)
pictureBox1.Image = BackImage


如果要让计时器移动覆盖的图像,则首先创建一个变量
Dim posX As Integer = 0
然后使用
g.DrawImage(OverlayImage,posX,0)
现在,当计时器计时时,将 posX 递增10

这篇关于VB.NET Winforms:覆盖两个透明图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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