我正在尝试使用代码在我的图片中创建一个洞,例如http://i1293.photobucket.com/albums/b595/electrogeekguy/fogofwardemo_zps6a6108c8.png
因此,当我绘制图像时,您可以看到穿过洞的下方。
下面是我的代码,它创建了一个在中间透明的渐变到边缘处的纯黑色,但它将我的渐变与底层黑色混合。
vb.net或c#代码可以帮到我。
我的计划是移除上图中的圆圈,然后应用渐变。
Private Function FogOfWarUpdate() As Image
Dim FogOfWarBitmap As Bitmap = New Bitmap(FogOfWarOldImage)
Dim FogOfWarGraphics As Graphics = Graphics.FromImage(FogOfWarBitmap)
Dim FogOfWarGraphicsPath As New System.Drawing.Drawing2D.GraphicsPath
FogOfWarGraphicsPath.AddEllipse(2048, 1024, 500, 500)
Dim FogOfWarPathGradientBrush As New System.Drawing.Drawing2D.PathGradientBrush(FogOfWarGraphicsPath)
FogOfWarPathGradientBrush.CenterPoint = New PointF(2048 + 250, 1024 + 250)
FogOfWarPathGradientBrush.CenterColor = Color.FromArgb(0, Color.Black)
FogOfWarPathGradientBrush.SurroundColors = New Color() {Color.FromArgb(128, Color.Black)}
FogOfWarGraphics.FillPath(FogOfWarPathGradientBrush, FogOfWarGraphicsPath)
'FogOfWarGraphics.DrawEllipse(Pens.BlueViolet, 100, 100, 200, 200)
FogOfWarPathGradientBrush.Dispose()
FogOfWarGraphicsPath.Dispose()
FogOfWarGraphics.Dispose()
Return FogOfWarBitmap
End Function