我试图在小的基础上创建噪波图像,但是,我无法使图像加载得足够快以显得逼真。我尝试使用ldarray,但它仍然不够快。
这是我正在使用的当前代码:
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计数器,那将非常有帮助,因为我不知道从哪里开始。
好吧,这似乎更快一些,但并不完美。这是您可以完成的艰巨任务之一,因为它需要使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)
EndWhile
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句