这个问题我百度了很久,也没查到这个函数,及函数的具体用法。
我参考画圆的函数试着声明了这样的画扇形函数
画圆的函数:Public Declare Function
GdipDrawEllipseI Lib "gdiplus" (ByVal Graphics As Long, ByVal pen As Long, ByVal x As Long, ByVal y As Long, ByVal Width As Long, ByVal Height As Long) As GpStatus
没查到画扇形的函数,我试着凑了一个:Public Declare Function
GdipDrawPie Lib "gdiplus" (ByVal Graphics As Long, ByVal pen As Long, ByVal x As Single, ByVal y As Single, ByVal Width As Single, ByVal Height As Single, ByVal X3 As Long, ByVal Y3 As Long) As GpStatus居然没有报错,但是,结果却画出了一个圆。
苦逼啊,有哪位高手可以求解吗?我的邮箱是chinacohit@163.COM QQ 1002031672
Public Sub 画圆(hDc As Long, ByVal 圆心X As Long, ByVal 圆心Y As Long, ByVal 宽度 As Long, ByVal 高度 As Long, _
ByVal 度起点 As Long, ByVal 度终点 As Long, ByVal 框线粗细 As Long, ByVal 线条类型 As 线条类型_m, ByVal 边框色 As Long, ByVal 填充色 As Long)
Dim pBrush As Long, pPen As Long
Dim X1 As Long, X2 As Long, X3 As Long, x4 As Long
Dim Y1 As Long, Y2 As Long, Y3 As Long, y4 As Long
Dim A As Single
If 填充色 < 0 Then
Call Arc(hDc, X1, Y1, X2, Y2, X3, Y3, x4, y4)
Else
Call Pie(hDc, X1, Y1, X2, Y2, X3, Y3, x4, y4)
End If
Call DeleteObject(SelectObject(hDc, pBrush))
Call DeleteObject(SelectObject(hDc, pPen))
End Sub
#3
半透明,可以先将扇形画到,P2,然后用
Public Function 半透明复制图2(ByVal 目标DC As Long, ByVal x目标 As Long, ByVal y目标 As Long, ByVal w目标 As Long, ByVal h目标 As Long, ByVal 源DC As Long, ByVal x源 As Long, ByVal y源 As Long, ByVal w源 As Long, ByVal h源 As Long, ByVal 透明度百分比 As Long) As Long
Dim lngBlend As Long
'lngBlend = Val("&h" & Hex(透明度) & "00" & "00")
lngBlend = RGB(0, 0, 255 - 2.55 * 透明度百分比)
AlphaBlending 目标DC, x目标, y目标, w目标, h目标, 源DC, x源, y源, w源, h源, lngBlend
End Function
P2 半透明复制到P1显示就可以了, Picture1 是显示用,Picture2隐藏
#4
研究了一下,搞定了。
把图片保存下来,修改后缀为ZIP即可解压看到工程文件。
#5
我奉劝这位仁兄凡是涉及到带alpha通道的半透明图形绘制还是早日放弃GDI,改用GDI+吧……
#6
me4405801 楼上的乃高人啊,测试完毕,基本是我想要的啊,非常感谢。保持联系啊!
#7
再次感谢楼上的,我仔细阅读了你的程序,你的扇形声明函数
Public Declare Function GdipDrawPieI Lib "gdiplus" (ByVal Graphics As Long, ByVal pen As Long, ByVal x As Long, ByVal y As Long, ByVal Width As Long, ByVal Height As Long, ByVal startAngle As Single, ByVal sweepAngle As Single) As GpStatus
我的自己瞎拼凑的扇形声明函数
'Public Declare Function GdipDrawPie Lib "gdiplus" (ByVal Graphics As Long, ByVal pen As Long, ByVal x As Single, ByVal y As Single, ByVal Width As Single, ByVal Height As Single, ByVal X3 As Long, ByVal Y3 As Long) As GpStatus
问题出在形参名称和类型都对不上。
Public Declare Function GdipDrawPieI Lib "gdiplus" (ByVal Graphics As Long, ByVal pen As Long, ByVal x As Long, ByVal y As Long, ByVal Width As Long, ByVal Height As Long, ByVal startAngle As Single, ByVal sweepAngle As Single) As GpStatus
我的自己瞎拼凑的扇形声明函数
'Public Declare Function GdipDrawPie Lib "gdiplus" (ByVal Graphics As Long, ByVal pen As Long, ByVal x As Single, ByVal y As Single, ByVal Width As Single, ByVal Height As Single, ByVal X3 As Long, ByVal Y3 As Long) As GpStatus
问题出在形参名称和类型都对不上。
Public Sub 画圆(hDc As Long, ByVal 圆心X As Long, ByVal 圆心Y As Long, ByVal 宽度 As Long, ByVal 高度 As Long, _
ByVal 度起点 As Long, ByVal 度终点 As Long, ByVal 框线粗细 As Long, ByVal 线条类型 As 线条类型_m, ByVal 边框色 As Long, ByVal 填充色 As Long)
Dim pBrush As Long, pPen As Long
Dim X1 As Long, X2 As Long, X3 As Long, x4 As Long
Dim Y1 As Long, Y2 As Long, Y3 As Long, y4 As Long
Dim A As Single
If 填充色 < 0 Then
Call Arc(hDc, X1, Y1, X2, Y2, X3, Y3, x4, y4)
Else
Call Pie(hDc, X1, Y1, X2, Y2, X3, Y3, x4, y4)
End If
Call DeleteObject(SelectObject(hDc, pBrush))
Call DeleteObject(SelectObject(hDc, pPen))
End Sub
#3
半透明,可以先将扇形画到,P2,然后用
Public Function 半透明复制图2(ByVal 目标DC As Long, ByVal x目标 As Long, ByVal y目标 As Long, ByVal w目标 As Long, ByVal h目标 As Long, ByVal 源DC As Long, ByVal x源 As Long, ByVal y源 As Long, ByVal w源 As Long, ByVal h源 As Long, ByVal 透明度百分比 As Long) As Long
Dim lngBlend As Long
'lngBlend = Val("&h" & Hex(透明度) & "00" & "00")
lngBlend = RGB(0, 0, 255 - 2.55 * 透明度百分比)
AlphaBlending 目标DC, x目标, y目标, w目标, h目标, 源DC, x源, y源, w源, h源, lngBlend
End Function
Public Declare Function GdipDrawPieI Lib "gdiplus" (ByVal Graphics As Long, ByVal pen As Long, ByVal x As Long, ByVal y As Long, ByVal Width As Long, ByVal Height As Long, ByVal startAngle As Single, ByVal sweepAngle As Single) As GpStatus
我的自己瞎拼凑的扇形声明函数
'Public Declare Function GdipDrawPie Lib "gdiplus" (ByVal Graphics As Long, ByVal pen As Long, ByVal x As Single, ByVal y As Single, ByVal Width As Single, ByVal Height As Single, ByVal X3 As Long, ByVal Y3 As Long) As GpStatus
问题出在形参名称和类型都对不上。
Public Declare Function GdipDrawPieI Lib "gdiplus" (ByVal Graphics As Long, ByVal pen As Long, ByVal x As Long, ByVal y As Long, ByVal Width As Long, ByVal Height As Long, ByVal startAngle As Single, ByVal sweepAngle As Single) As GpStatus
我的自己瞎拼凑的扇形声明函数
'Public Declare Function GdipDrawPie Lib "gdiplus" (ByVal Graphics As Long, ByVal pen As Long, ByVal x As Single, ByVal y As Single, ByVal Width As Single, ByVal Height As Single, ByVal X3 As Long, ByVal Y3 As Long) As GpStatus
问题出在形参名称和类型都对不上。
Public Declare Function GdipDrawPieI Lib "gdiplus" (ByVal Graphics As Long, ByVal pen As Long, ByVal x As Long, ByVal y As Long, ByVal Width As Long, ByVal Height As Long, ByVal startAngle As Single, ByVal sweepAngle As Single) As GpStatus
我的自己瞎拼凑的扇形声明函数
'Public Declare Function GdipDrawPie Lib "gdiplus" (ByVal Graphics As Long, ByVal pen As Long, ByVal x As Single, ByVal y As Single, ByVal Width As Single, ByVal Height As Single, ByVal X3 As Long, ByVal Y3 As Long) As GpStatus
问题出在形参名称和类型都对不上。