Closed lua-rocks closed 3 years ago
This should get you the pixel values as numbers from 0 to 255.
local lgi = require "lgi"
local Gtk = lgi.require "Gtk"
local Gdk = lgi.require "Gdk"
local function get_pixel_color(x, y)
local w = Gdk.get_default_root_window()
local pb = Gdk.pixbuf_get_from_window(w, x, y, 1, 1)
local pixels = pb:get_pixels()
return string.byte(pixels, 1, #pixels)
end
print(get_pixel_color(10, 10))
@psychon Thank you so much!
I'm trying to make a simple colorpicker. Currently it returns color in raw format (like this "���") and I have no idea how to fix it.