Colour of a pixel on the screen.

Is it possible to get the colour of a pixel on the screen? If so, how?

[editline]09:49PM[/editline]

I don’t want the colour of the surface the player is looking at (render.GetSurfaceColor). I need the actual colour of a pixel.

Well, you can do it in 3d…

Depends how you want to use it, if you want a sort of “paint” lua app, you can create a separate VGUI panel, but without one of those. I have no idea how to retrieve it.

Problem solved with a module, albeit a crappy one.

Care sharing?

If you really want a module that drops my framerate to 20fps when calling the function once a frame, then yes, you can have it.

[editline]07:59PM[/editline]

Just realised the module doesn’t work. It seems to only return either a dark grey, or a light red colour.

gm_image



rt = render.GetRenderTarget( )
w, h = rt:GetActualWidth( ), rt:GetActualHeight( )
img = image:CreateImage( 0, 0 )
img:CopyRenderTarget( rt, 0, 0, w, h )

return img:GetPixel( x, y )


According to Jinto’s post there, this isn’t a viable method but is probably the best you are going to be able to do currently with what is released.

I thought about using gm_image, but as Jinto said, it is too slow to be used in realtime. I needed to call it at least once a frame.

[editline]09:48PM[/editline]

I don’t need this any more, but thanks for the suggestions.