Jian said:
can wxRuby get a pixel's color value off from the screen too? (not
window but the screen)
If you create the window like I showed, it will fill the *entire*
screen. There's nothing else than the window to see (not even the
taskbar!), so it's equivalent if you get the pixel from your window or
the screen. And so does it work:
-------------------------
require "wx"
class MyApp < Wx::App
include Wx
def on_init
@mainwindow = Frame.new(nil, -1, "", DEFAULT_POSITION, DEFAULT_SIZE,
MAXIMIZE)
@mainwindow.background_colour = BLACK
Timer.after(3000) do
@mainwindow.paint do |dc|
dc.pen = WHITE_PEN
dc.draw_line(0, 0, 500, 500)
#Get the pixel color at (100|10) which should be black.
col = Colour.new(255, 255, 255) #This means white
dc.get_pixel(100, 10, col)
p col #=> (0, 0, 0) #This means black
end
end
Timer.after(5000){@mainwindow.close}
@mainwindow.show
end
end
x = MyApp.new
x.main_loop
------------------------
The #get_pixel method seems to be directly imported from C, because it
works like it would require a pointer. However, it works. The method to
set a pixel directly, is #draw_point.
Marvin