2014-01-30 13:35:29 +01:00
|
|
|
|
|
|
|
// Hyperion-X11 includes
|
|
|
|
#include "X11Wrapper.h"
|
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
X11Wrapper::X11Wrapper(int grabInterval, int cropLeft, int cropRight, int cropTop, int cropBottom, int pixelDecimation) :
|
2016-05-26 23:44:27 +02:00
|
|
|
_timer(this),
|
2018-12-27 23:11:32 +01:00
|
|
|
_grabber(cropLeft, cropRight, cropTop, cropBottom, pixelDecimation)
|
2014-01-30 13:35:29 +01:00
|
|
|
{
|
2016-05-26 23:44:27 +02:00
|
|
|
_timer.setSingleShot(false);
|
|
|
|
_timer.setInterval(grabInterval);
|
2014-12-01 20:24:53 +01:00
|
|
|
|
2016-05-26 23:44:27 +02: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()
|
|
|
|
{
|
2017-08-12 07:55:32 +02:00
|
|
|
_grabber.grabFrame(_screenshot, true);
|
|
|
|
return _screenshot;
|
2014-01-30 13:35:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void X11Wrapper::start()
|
|
|
|
{
|
2016-05-26 23:44:27 +02:00
|
|
|
_timer.start();
|
2014-01-30 13:35:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void X11Wrapper::stop()
|
|
|
|
{
|
2016-05-26 23:44:27 +02:00
|
|
|
_timer.stop();
|
2014-01-30 13:35:29 +01:00
|
|
|
}
|
|
|
|
|
2016-01-21 16:41:37 +01:00
|
|
|
bool X11Wrapper::displayInit()
|
|
|
|
{
|
2016-05-26 23:44:27 +02:00
|
|
|
return _grabber.Setup();
|
2016-01-21 16:41:37 +01:00
|
|
|
}
|
|
|
|
|
2014-01-30 13:35:29 +01:00
|
|
|
void X11Wrapper::capture()
|
|
|
|
{
|
2018-12-28 18:12:45 +01:00
|
|
|
_grabber.grabFrame(_screenshot, !_inited);
|
2017-08-12 07:55:32 +02:00
|
|
|
emit sig_screenshot(_screenshot);
|
2018-12-28 18:12:45 +01:00
|
|
|
_inited = true;
|
2014-01-30 13:35:29 +01:00
|
|
|
}
|
2016-06-07 23:12:18 +02:00
|
|
|
|
|
|
|
void X11Wrapper::setVideoMode(const VideoMode mode)
|
|
|
|
{
|
|
|
|
_grabber.setVideoMode(mode);
|
|
|
|
}
|