VB 用Slider控件调整图片透明度,急!
VB中使用Slider控件调整图片的透明度,图片放在控件image里面Slider调整图片透明度,透明度在0~100之间,VB,调整以后的图片可以保存就像PS调整透明度那...
VB中使用Slider控件调整图片的透明度,图片放在控件image里面
Slider调整图片透明度,透明度在0~100之间,VB,
调整以后的图片可以保存
就像PS调整透明度那样,谢谢!
急急急急急急急急急急急急急急急急急急急急急急急急!
可追加分 展开
Slider调整图片透明度,透明度在0~100之间,VB,
调整以后的图片可以保存
就像PS调整透明度那样,谢谢!
急急急急急急急急急急急急急急急急急急急急急急急急!
可追加分 展开
1个回答
展开全部
打开VB建立一个新工程。选择 菜单-工程-添加模块 添加一个模块到工程中,在其中输入以下代码:
Public Type rBlendProps
tBlendOp As Byte
tBlendOptions As Byte
tBlendAmount As Byte
tAlphaType As Byte
End Type
Public Declare Function AlphaBlend Lib "msimg32" (ByVal hDestDC As Long, _
ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal hSrcDC As Long, _
ByVal xSrc As Long, ByVal ySrc As Long, ByVal widthSrc As Long, _
ByVal heightSrc As Long, ByVal blendFunct As Long) As Boolean
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Any, Source As Any, ByVal Length As Long)
在Form1中添加两个PictureBox控件,其中Picture2为源,Picture1为拷贝目标,将两者的ScaleMode都设置为3-Pixel将两者的AutoRedraw属性都设置为True,然后分别添加图像。在加入一个Slider控件,然后在Form1的代码窗口中添加如下代码:
Sub ShowTransparency(cSrc As PictureBox, cDest As PictureBox, _
ByVal nLevel As Byte)
Dim LrProps As rBlendProps
Dim LnBlendPtr As Long
cDest.Cls
LrProps.tBlendAmount = nLevel
CopyMemory LnBlendPtr, LrProps, 4
With cSrc
AlphaBlend cDest.hDC, 0, 0, .ScaleWidth, .ScaleHeight, _
.hDC, 0, 0, .ScaleWidth, .ScaleHeight, LnBlendPtr
End With
cDest.Refresh
End Sub
Private Sub Form_Load()
Picture2.Picture = LoadPicture("D:\a.jpg") '源图片路径
Slider1.Max = 100
Slider1.Min = 0
End Sub
Private Sub Slider1_Click()
ShowTransparency Picture2, Picture1, Slider1.Value * 2.5
End Sub
Public Type rBlendProps
tBlendOp As Byte
tBlendOptions As Byte
tBlendAmount As Byte
tAlphaType As Byte
End Type
Public Declare Function AlphaBlend Lib "msimg32" (ByVal hDestDC As Long, _
ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal hSrcDC As Long, _
ByVal xSrc As Long, ByVal ySrc As Long, ByVal widthSrc As Long, _
ByVal heightSrc As Long, ByVal blendFunct As Long) As Boolean
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Any, Source As Any, ByVal Length As Long)
在Form1中添加两个PictureBox控件,其中Picture2为源,Picture1为拷贝目标,将两者的ScaleMode都设置为3-Pixel将两者的AutoRedraw属性都设置为True,然后分别添加图像。在加入一个Slider控件,然后在Form1的代码窗口中添加如下代码:
Sub ShowTransparency(cSrc As PictureBox, cDest As PictureBox, _
ByVal nLevel As Byte)
Dim LrProps As rBlendProps
Dim LnBlendPtr As Long
cDest.Cls
LrProps.tBlendAmount = nLevel
CopyMemory LnBlendPtr, LrProps, 4
With cSrc
AlphaBlend cDest.hDC, 0, 0, .ScaleWidth, .ScaleHeight, _
.hDC, 0, 0, .ScaleWidth, .ScaleHeight, LnBlendPtr
End With
cDest.Refresh
End Sub
Private Sub Form_Load()
Picture2.Picture = LoadPicture("D:\a.jpg") '源图片路径
Slider1.Max = 100
Slider1.Min = 0
End Sub
Private Sub Slider1_Click()
ShowTransparency Picture2, Picture1, Slider1.Value * 2.5
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询