def _get_pixbuf_pixel(pb: GdkPixbuf.Pixbuf, x, y): bytes = pb.get_pixels() n_channels = pb.get_n_channels() rowstride = pb.get_rowstride() bps = pb.get_bits_per_sample() bytes_per_pixel = int(n_channels * bps / 8) offset = y * rowstride + x * bytes_per_pixel return list(bytes[offset:offset + bytes_per_pixel])