bmax to blitz3d acces writepixel

BlitzMax Forums/BlitzMax Programming/bmax to blitz3d acces writepixel

mongia2(Posted 2007) [#1]
blitz3d 20 millisecs()
bmax 60 millisecs()

bmax is slowwww




you use a yourimage


Graphics 800,600,0

Local image:timage
Local x,y
Local pixmap:TPixmap


image=LoadImage:TImage("yourimage.jpg")

te=MilliSecs()

pixmap=LockImage(image)
For y=0 Until image.height
For x=0 Until image.width

argb=-Rnd(160000)-1
WritePixel(pixmap,x,y,argb)

Next
Next


UnlockImage image

tempo=MilliSecs()-te

While Not KeyDown(key_escape)

DrawImage image,0,0


DrawText tempo,610,10


Flip

Wend
End



; example blitz3d
Graphics 800,600,0,2
SetBuffer BackBuffer()


image=LoadImage("yourimage.jpg")


te=MilliSecs()

SetBuffer ImageBuffer(image)
LockBuffer ImageBuffer(image)

For xx=0 To ImageWidth(image)-1
For yy=0 To ImageHeight(image)-1
WritePixelFast(xx,yy,Rnd(-65000)-5,ImageBuffer(image))
Next
Next

UnlockBuffer ImageBuffer(image)
SetBuffer BackBuffer()

tempo=MilliSecs()-te


While Not KeyDown(1)

DrawImage image,0,0


Text 610,10,tempo


Flip

Wend
End


ImaginaryHuman(Posted 2007) [#2]
Try getting the base pointer of the pixmap with PixmapPtr, convert it to an Int Pointer, then do MyIntPtr[Offset]=-Rnd(160000)-1 and see how that compares.

Local MyIntPtr:Int Ptr=Int Ptr(PixmapPtr(pixmap))
Local MyRowSize:Int=PixmapPitch(pixmap)/4
...

MyIntPtr[x+(y*MyRowSize)]=-Rnd(160000)-1


See if that's faster.


tonyg(Posted 2007) [#3]
Isn't it the rnd command that's quicker? Bmax writepixel seems quicker than writepixelfast as far as I can see.
<edit> Probably messed something up on the B3D side of things as it's been a while :




mongia2(Posted 2007) [#4]
ok!
i tested without rnd

blitz3d it fast bmax!

11 millisecs()


tonyg(Posted 2007) [#5]
You might want to post the code you tested with.
What was the result of running the code I posted above?