我有一点问题,当我尝试以下操作时,我无法使代码正常工作:
Dim filename As String = "C:\Users\NahNah\Desktop\HeightMap.png"
IO.File.Create(filename)
Dim h As New Structures.HeightMap(1, 10, 512)
Dim graph As Graphics = CreateGraphics()
Dim png As New Bitmap(filename)
graph.DrawImage(png, Width, Height)
h.Generate()
graph = h.Draw(graph)
graph.DrawImage(png, 1024, 1024)
png.Save(filename)
我在第
行获得了一个Argument异常 Dim png As New Bitmap(filename)
正如你所看到的,我真的不知道我在做什么,我需要帮助。感谢
答案 0 :(得分:1)
当然失败了......
IO.File.Create(filename)
......
Dim png As New Bitmap(filename)
当您尝试打开一个有效位图的空文件时,您会发生什么?
虽然我错过了很多细节(结构及其参数是一个谜,你在哪里得到Width和Heigth ......),我认为你应该遵循这个方法
Dim h As New Structures.HeightMap(1, 10, 512)
Using png As New Bitmap(Width, Height)
Using graph = Graphics.FromImage(png)
h.Generate()
graph.DrawImage(png, 1024, 1024)
png.Save(filename)
End Using
End Using