2014-01-30 13:35:29 +01:00
|
|
|
|
|
|
|
// Hyperion-X11 includes
|
|
|
|
#include "X11Wrapper.h"
|
|
|
|
|
2014-12-14 14:26:59 +01:00
|
|
|
X11Wrapper::X11Wrapper(int grabInterval, int cropLeft, int cropRight, int cropTop, int cropBottom, int horizontalPixelDecimation, int verticalPixelDecimation) :
|
2014-11-21 21:24:33 +01:00
|
|
|
_timer(this),
|
2014-12-14 14:26:59 +01:00
|
|
|
_grabber(cropLeft, cropRight, cropTop, cropBottom, horizontalPixelDecimation, verticalPixelDecimation)
|
2014-01-30 13:35:29 +01:00
|
|
|
{
|
2014-12-01 20:24:53 +01:00
|
|
|
_timer.setSingleShot(false);
|
|
|
|
_timer.setInterval(grabInterval);
|
|
|
|
|
2014-11-21 21:24:33 +01:00
|
|
|
// Connect capturing to the timeout signal of the timer
|
|
|
|
connect(&_timer, SIGNAL(timeout()), this, SLOT(capture()));
|
2014-01-30 13:35:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const Image<ColorRgb> & X11Wrapper::getScreenshot()
|
|
|
|
{
|
2014-11-21 21:24:33 +01:00
|
|
|
const Image<ColorRgb> & screenshot = _grabber.grab();
|
|
|
|
return screenshot;
|
2014-01-30 13:35:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void X11Wrapper::start()
|
|
|
|
{
|
2014-12-01 20:24:53 +01:00
|
|
|
_timer.start();
|
2014-01-30 13:35:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void X11Wrapper::stop()
|
|
|
|
{
|
2014-11-21 21:24:33 +01:00
|
|
|
_timer.stop();
|
2014-01-30 13:35:29 +01:00
|
|
|
}
|
|
|
|
|
2016-01-21 16:41:37 +01:00
|
|
|
bool X11Wrapper::displayInit()
|
|
|
|
{
|
|
|
|
return _grabber.Setup();
|
|
|
|
}
|
|
|
|
|
2014-01-30 13:35:29 +01:00
|
|
|
void X11Wrapper::capture()
|
|
|
|
{
|
2014-11-21 21:24:33 +01:00
|
|
|
const Image<ColorRgb> & screenshot = _grabber.grab();
|
|
|
|
emit sig_screenshot(screenshot);
|
2014-01-30 13:35:29 +01:00
|
|
|
}
|