0
我在vb.net中将可变大小的窗口滑过二维数组时出现问题。当我将数组的第一个元素设置为0,0时,我的问题是,窗口的大小需要变小,因为所讨论的元素必须是滑动窗口的中心。例如:arrar大小(40,43)窗口大小5x5(窗口大小是NxN N = 3胜大小是3x3)所以数组(0,0)与胜利大小5所以2 col和2行需要cout和一个新的窗口大小为3x3。任何帮助,将great.`vb.net中的2d数组滑动窗口
Public Function getPIXELSinWINDOW(ByVal Wsize As Integer, ByVal x As Integer, ByVal y As Integer)
Dim tempARRAY As New ArrayList()
Dim Xwidth As Integer = Wsize
Dim Yheight As Integer = Wsize
Dim Xvalue As Integer = x - Wsize/2
Dim Yvalue As Integer = y - Wsize/2
Dim imgHEIGHT As Integer = Me.mysize.Height
Dim imgWIDTH As Integer = Me.mysize.Width
Dim i, j As Integer
While Xvalue < 0
Xvalue += 1
Xwidth -= 1
End While
While Xvalue > imgWIDTH
Xvalue -= 1
Xwidth -= 1
End While
While Xwidth >= imgWIDTH
Xwidth -= 1
End While
While Xvalue + Xwidth > imgWIDTH
Xwidth -= 1
End While
While Yvalue < 0
Yvalue += 1
Yheight -= 1
End While
While Yvalue > imgHEIGHT
Yvalue -= 1
Yheight -= 1
End While
While Yheight >= imgHEIGHT
Yheight -= 1
End While
While Yvalue + Yheight > imgHEIGHT
Yheight -= 1
End While
For i = Xvalue To Xvalue + Xwidth
For j = Yvalue To Yvalue + Yheight
tempARRAY.Add(pixels(j, i))
Next
Next
Return tempARRAY
End Function
了var像素是二维数组
噢,抱歉在C#中的例子,但我希望你能理解它! :) – ManiSto
即时通讯不知道如何阅读这个权利,但如果在数据阵列20,10即时通讯将会给我25个值的完整窗口? – bob
是的。您可以创建一个控制台项目,粘贴此类并将其作为主类运行。这样你可以玩不同的值来确保它按预期工作。另外,如果您愿意,我可以添加更多代码评论的版本。 – ManiSto