我试图创造一个噪音图像的小基础,然而,我无法获得足够快的图像加载,以看上去现实。我试过用伊达雷,但还是不够快。
下面是使用以下方法的当前代码im:
GraphicsWindow.Left = 0 'positions graph
GraphicsWindow.Top = 0
GraphicsWindow.Height = 240
GraphicsWindow.Width = 320
numpix = 320 * 240 'creates number of indices for ldarray
pixels = LDArray.Create(numpix) 'creates 1D array where color values will be stored
While 1=1
setcolor()
importcolor()
EndWhile
Sub setcolor
For h = 1 To numpix
randomcolor = Math.GetRandomNumber(2)
If randomcolor = 1 Then
ldarray.SetValue(pixels,h,"black") 'sets the pixel color to black or white
Else
ldarray.SetValue(pixels,h,"white")
EndIf
EndFor
EndSub
sub importcolor
'prints out the image
For h = 1 To 320
For w = 1 To 240
i = i + 1
color = LDArray.GetValue(pixels,i)
GraphicsWindow.SetPixel(h,w,color)
EndFor
EndFor
EndSub您可以通过选择所有文本,然后单击“格式化程序”,将格式设置为以后的程序。
另外,如果你能帮我写一个fps计数器,那将是非常有帮助的,因为我不知道从哪里开始。
发布于 2016-08-14 05:39:24
嗯,这看起来有点快,但并不完美。这是你能做的更难的任务之一,因为它需要使76,800像素中的每一个像素同时随机化。非常难。
GraphicsWindow.Left = 0 'positions graph
GraphicsWindow.Top = 0
GraphicsWindow.Height = 240
GraphicsWindow.Width = 320
Randcol[1] = "Black"
Randcol[2] = "White"
'Load a random image of the right size into the imagelist
img = ImageList.LoadImage("http://www.hdiphonewallpapers.us/phone-wallpapers/freewallpaper/12954B94004N0-1Da.jpg")
LDImage.OpenWorkingImage(img)
While 1=1
For x = 1 To 320
For y = 1 to 240
LDImage.SetWorkingImagePixel(img,x,y,Randcol[Math.GetRandomNumber(2)])
EndFor
EndFor
LDImage.CloseWorkingImage(img)
GraphicsWindow.DrawImage(img,0,0)
LDImage.OpenWorkingImage(img)
EndWhilehttps://stackoverflow.com/questions/38855428
复制相似问题