Bonjour,
Je voudrais savoir comment récupérer le code couleur en hexa du pixel sous la souris a une position (x,y) sans cliquer. (Si possible sans capture d'image).
ex: if mousepixelat(320,100) & color = 0x00FFFF00 then cmd
voilà, merci pour l'aide![]()
Bonjour,
Je voudrais savoir comment récupérer le code couleur en hexa du pixel sous la souris a une position (x,y) sans cliquer. (Si possible sans capture d'image).
ex: if mousepixelat(320,100) & color = 0x00FFFF00 then cmd
voilà, merci pour l'aide![]()
Assuming you mean using C and GTK the answer can be using:
And
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 gdk_get_default_root_window()
EDIT: sample c++ code using Gdkmm (note that this is just a sample that assume an RGB color space, you should check the colorspace of the drawable before giving a meaning to the raw bytes).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 GdkPixbuf* gdk_pixbuf_get_from_drawable (GdkPixbuf *dest, GdkDrawable *src, GdkColormap *cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height);
Voilà, j'ai trouvé ca mais comment ca fonctionne ? :X
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #include <iostream> #include <gtkmm.h> #include <gdkmm.h> int main(int argc, char* argv[]) { Gtk::Main kit(argc, argv); if(argc != 3) { std::cerr << argv[0] << " x y" << std::endl; return 1;} int x = atoi(argv[1]); int y = atoi(argv[2]); Glib::RefPtr<Gdk::Screen> screen = Gdk::Screen::get_default(); Glib::RefPtr<Gdk::Drawable> win = screen->get_root_window(); Glib::RefPtr<Gdk::Pixbuf> pb = Gdk::Pixbuf::create(win, x, y, 1, 1); unsigned char* rgb = pb->get_pixels(); std::cerr << (int)rgb[0] << ", " << (int)rgb[1] << ", " << (int)rgb[2] << std::endl; return 0; }
Partager