Commit db82ac3e authored by abmyii's avatar abmyii
Browse files

Implement mirroring the image

parent 6df7aa14
Pipeline #233040339 passed with stage
in 3 minutes and 28 seconds
......@@ -75,6 +75,7 @@ struct libevdev_uinput *uidev;
int maxx, maxy;
bool landscape = false;
bool mirror = false;
float scale_factor;
bool lmb;
......@@ -96,6 +97,23 @@ void read_pixels(int bpp, GLenum format, mir::geometry::Size const& size, std::v
std::vector<char> pixels(bpp * width * height);
glReadPixels(0, 0, width, height, format, GL_UNSIGNED_BYTE, pixels.data());
// Mirror image
if (mirror) {
std::vector<char> mirrored(bpp * width * height);
int i = 0;
for (int y = height; y > 0; y--) {
for (int x = width*bpp; x > 0; x -= bpp) {
int offset = (width * bpp * y) + x;
for (int p = 0; p < bpp; p++)
mirrored[i+p] = pixels[offset-bpp+p];
i += bpp;
}
}
pixels = mirrored;
}
// Rotate to landscape
if (landscape) {
/** Starts from the last column and moves back reading each vertically and writing it horizontally.
......@@ -507,6 +525,11 @@ static void doptr(int buttonMask, int x, int y, rfbClientPtr cl)
int right_down = buttonMask & 0x4;
int middle_down = buttonMask & 0x2;
if (mirror) {
y = maxy - y;
x = maxx - x;
}
if (landscape) {
x = maxx - x;
std::swap(x, y);
......@@ -679,6 +702,8 @@ try
("file,f",
po::value<std::string>(&output_filename), "output filename (default is /tmp/mir_screencast_<w>x<h>.<rgba|bgra>")
("landscape", po::value<bool>(&landscape)->zero_tokens(), "landscape mode - note width and height are automatically swapped")
("mirror", po::value<bool>(&mirror)->zero_tokens(),
"mirrored image; use alone for upside-down portrait mode and in combination with --landscape for clockwise landscape")
("size,s",
po::value<std::vector<int>>(&requested_size)->multitoken(),
"screencast size [width height]")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment