ReadPixelFast

Blitz3D Forums/Blitz3D Programming/ReadPixelFast

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Sure, something simple would be like,

type img
     field pix,w,h
end type

function createFast(x,y,w,h)
   o.img=new img
   bank=createBank( w*h*3)
lockbuffer
   for gy=x to y+h
   for gx=x to x+w
        pokeint bank,bo,readpixelfast(gx,gy)
        bo=bo+4
   next
   next
unlockbuffer
o\pix=bank
return handle(o)
end function

and then pass the returned handle to this func to retrieve pixel color very fastly.

function readPixelFastest( img,x,y)
     in.img=object.img(img)
     return peekint(in\pix,(y*in\w+x)*4)
end function




Although I strongly suggest accessing the bank directly using the same method as readpixel fastest above does, rather calling a function to do it, as that adds a lot of unneded overhead.