UnderwareDESIGN

PlayBASIC => Resources => Source Codes => Topic started by: kevin on February 28, 2007, 08:45:14 AM

Title: Screen/Image Direct Memory Access
Post by: kevin on February 28, 2007, 08:45:14 AM
 This Tidbit shows how you can use GetImagePtr to access the backbuffer directly.

[pbcode]

ScreenWidth      =640
ScreenHeight   =400

openscreen ScreenWidth,ScreenHeight,32,1


Dim Ptr as pointer

if GetScreenDepth()=32
  Lockbuffer
   Ptr =getimageptr(0)
   Pitch =getimagepitch(0)
   Depth =getimagedepth(0)

      For ylp=0 to ScreenHeight-1
         Dim LinePtr as integer pointer
         LinePtr =Ptr+Ylp*Pitch
         For xlp=0 to ScreenWidth-1
            *LinePtr=rgb(ylp,xlp*ylp,xlp)   
            LinePtr=LInePtr+1
         next
      next
  UnLockbuffer
endif
print int(ptr)
print Pitch
print depth

sync
waitkey

[/pbcode]