PNG图片本身设置通道,使用Adobe Photoshop加入这个通道这样就肯定没白边了
专业成都网站建设公司,做排名好的好网站,排在同行前面,为您带来客户和效益!创新互联为您提供成都网站建设,五站合一网站设计制作,服务好的网站设计公司,成都网站设计、成都网站制作负责任的成都网站制作公司!
这方面的知识属于Photoshop绘图相关的
通道的意思就是为这个时钟设置一个选择范围蒙板,屏蔽除时钟这个大圆形外的其它部分
加入通道后,把时钟外其它部分图像填充蓝色
这方面还有一些专用的技巧的,如通道设置的这个圆形范围周围做模糊处理之类的,说起来很复杂你也看不明白。你网上找一下有没有Photoshop加入通道演示的内容吧
这种功能读winform来说只有容器才能设置透明度,如form、panel类控件,其他的不是不可以,要重写背景参数,而且重写完了后与win7、Xp互不兼容,闪烁,并不提倡。.net的解决办法是wpf,控件可以设置opation属性,灵活控制透明度,并且后台静态刷新,因为他是xaml机制构造。
将窗体的transparencykey属性设置为与窗体的backcolor属性相同,看看是不是你要的效果。
窗体透明,控件不透明的代码:
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const WS_EX_LAYERED = H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = H2
Private Const LWA_COLORKEY = H1
Private Sub Form_Load()
Me.BackColor = HFF0000
Dim rtn As Long
Dim BorderStyler
BorderStyler = 0
rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes hwnd, HFF0000, 0, LWA_COLORKEY
End Sub
窗体逐渐变透明:
'添加一个PicturebBox,依它为容器添加一个shape,背景色设为蓝色
'添加一个时钟控件
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Const WS_EX_LAYERED = H80000
Const GWL_EXSTYLE = (-20)
Const LWA_ALPHA = H2
Const LWA_COLORKEY = H1
Dim tmd As Long
Private Sub Form_Load()
Show
Shape1.BackColor = H80000002
Shape1.BackStyle = 1
tmd = 255
Timer1.Interval = 50
Shape1.Width = Picture1.Width
SetWindowLong hwnd, GWL_EXSTYLE, WS_EX_LAYERED
SetLayeredWindowAttributes hwnd, 0, tmd, LWA_ALPHA '越少越透明,限制0-255
End Sub
Private Sub Timer1_Timer()
On Error Resume Next
tmd = tmd - 1
SetLayeredWindowAttributes hwnd, 0, tmd, LWA_ALPHA
Shape1.Width = Shape1.Width - Picture1.Width / 255
If tmd 0 Then
Timer1.Enabled = False
MsgBox "OK!"
End If
End Sub
简单的部分透明比较难做,不过可以换个方式考虑一下。
把本问题转换成在VB.NET 2005环境下创建不规则窗体(=普通窗体 - 透明部分)问题,解决方法就很多了,网上也有许多例子。如 章立民 的书里就详细讲过。
大致思路如下:
1。将backgroundimage设成一个位图(点阵图)
2.将Transparaencykey设成位图的背景颜色(位图最取背景单纯,单纯部分将成为透明部分)
3.如需要可以将formborderstyle设为none,会移除标题栏,并需要手动编写窗体移动、关闭等动作代码,
Option Explicit
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, _
ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, _
ByVal hObject As Long) As Long
Private Sub Form_Load()
Form1.BorderStyle = 0
Dim Bitmap
Me.AutoRedraw = True
Bitmap = CreateCompatibleBitmap(Me.hdc, 0, 0)
SelectObject Me.hdc, Bitmap '设置窗体透明
End Sub
Private Sub Form_Click()
End '单击窗体任何地方都是退出程序
End Sub
自己写的一段代码。你看一下吧。。我写是完全的。直接没有了标题栏,如果想要标题栏的话。把其中的 Form1.BorderStyle = 0 这句去掉就可以了。
售后响应及时
7×24小时客服热线数据备份
更安全、更高效、更稳定价格公道精准
项目经理精准报价不弄虚作假合作无风险
重合同讲信誉,无效全额退款