I got some help before about using GetPixel_(), but it seems to be constrained to certain windows. The code was:
Code: Select all
Define hwnd, hdc, pt.Point,p1.Point, rc.RECT, x, y
Define wid = 3, hig = 3,size = 50
Dim color(wid,hig)
OpenWindow(0,0,0,wid*size,hig*size,"", #PB_Window_Tool|#PB_Window_SystemMenu)
CanvasGadget(0,5,5,WindowWidth(0)-10,WindowHeight(0)-10)
StickyWindow(0, 1)
Repeat
Define time = ElapsedMilliseconds()
If pt\x <> DesktopMouseX() Or pt\y <> DesktopMouseY()
pt\x = DesktopMouseX()
pt\y = DesktopMouseY()
hwnd = WindowFromPoint_(PeekQ(pt))
If hwnd
hdc = GetDC_(hwnd)
If hdc
For y = 0 To hig-1
For x = 0 To wid-1
p1\x = pt\x + x - wid/2
p1\y = pt\y + y - hig/2
If ScreenToClient_(hwnd , p1)
color(x, y) = GetPixel_(hdc, p1\x, p1\y)
EndIf
Next
Next
ReleaseDC_(hwnd, hdc)
EndIf
EndIf
SetWindowTitle(0, Str(ElapsedMilliseconds() - time) + " ms")
StartDrawing(CanvasOutput(0))
For y = 0 To hig-1
For x = 0 To wid-1
Box(OutputWidth()/wid*x,OutputHeight()/hig*y,OutputWidth()/wid,OutputHeight()/hig,color(x,y))
Next
Next
StopDrawing()
EndIf
While WindowEvent():If Event()=#PB_Event_CloseWindow:End:EndIf:Wend
ForEver

