Reading a pixel

BlitzMax Forums/BlitzMax Beginners Area/Reading a pixel

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

Hi
@Xmicky: Why you dont use GrabPixmap direct?
My Solution:


Strict

Graphics 800,600,0




Repeat
   Cls

   SetColor 255,0,0
   Plot 60,60

   Local r,g,b
   ColorOnPosition(60,60,r,g,b)

   SetColor 255,255,255
   DrawText "RED: "+r, 10,10
   DrawText "GREEN: "+g,10,30
   DrawText "BLUE: "+b,10,50


   Flip
   FlushMem()
Until KeyHit(KEY_ESCAPE)


Function ColorOnPosition(x:Int, y:Int, r:Int Var, g:Int Var, b:Int Var)
   Local TempPixmap:TPixmap = GrabPixmap(x,y,1,1)
   Local TempPtr:Byte Ptr = TempPixmap.PixelPtr(0,0)
   r = TempPtr[2]
   g = TempPtr[1]
   b = TempPtr[0]
End Function

Mfg suco