Pixel Manipulating

BlitzMax Forums/BlitzMax Beginners Area/Pixel Manipulating

This takes 130ms to change an 800*600 png file.
Graphics 800,600,32,0
image2 = LoadImage("writepixel_test.png",dynamicimage)
While Not KeyHit(key_escape)
   Cls
   tg_pix3:Tpixmap = LockImage(image2)
   start_time = MilliSecs()
      If flop=1
         For x = 0 To ImageWidth(image2)-1
            For y = 0 To ImageHeight(image2)-1
               argb=ReadPixel(tg_Pix3,x,y)
               WritePixel(tg_pix3,x,y,$ffff0000)
            Next
         Next
         flop=0
      Else
         For x = 0 To ImageWidth(image2)-1
            For y = 0 To ImageHeight(image2)-1
               argb=ReadPixel(tg_Pix3,x,y)
               WritePixel(tg_pix3,x,y,$ff00ff00)
            Next
         Next
         flop=1
      EndIf
   stop_time=MilliSecs()
   UnlockImage(Image2)
   DrawImage image2,0,0
   total_time = stop_time - start_time
   DrawText("Total_time : " + total_time,100,10)
   Flip
Wend

In fact I added a timer for each stage.
The initial lock is nominal (0-1ms), Convert about 120ms
and unlock 10ms
Don't forget there's also the blend modes.
Similar test in B3D/B2D takes about 350-400ms