Pixel Manipulating

BlitzMax Forums/BlitzMax Beginners Area/Pixel Manipulating

Clyde(Posted 2005) [#1]
As with previous Blitz Flavours, you could do all kinds of funky stuff with WP / WPF. Where you'd load in and store pixel colouring information from imagebuffers (ReadPixelFast) to do stuff like: Image Fades, AA Blurring, Colour cycling, etc.. etc..

I managed to do a blurring effect with averaging out red, green and blue colours with arrays, but it was way too slow with using setcolor and plot; in a res of 640 x 480.

Is this sort of stuff possible to do with Beta Max?


ImaginaryHuman(Posted 2005) [#2]
It could be done faster with direct OpenGl programming I guess. Like, using a vertex array or something.


Robert(Posted 2005) [#3]
Actually changing the pixels in a Pixmap takes no time at all. What takes the time is the UnlockImage call which copies the new texture back to video memory.

If you divided your main image up into several smaller images (say 128x128) then you could do it very quickly.


tonyg(Posted 2005) [#4]
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


Perturbatio(Posted 2005) [#5]
takes about 80ms for me and can I just say... ouch!


tonyg(Posted 2005) [#6]
Yeah sorry.
Warning : Nasty flashing colours alert. Something you didn't have to worry about with Blitzbasic.


Clyde(Posted 2005) [#7]
Thanks for this, will see if I can make some nice blur and transition effects with it, after my eyes stop seeing flashes of yellow.