1

我正在尝试使用代码在我的图像中创建一个洞,例如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
4

0 回答 0