2015-01-18 00:04:45 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// Utils includes
|
|
|
|
#include <utils/Image.h>
|
2015-01-24 23:42:22 +01:00
|
|
|
#include <utils/ColorRgb.h>
|
2015-01-18 00:04:45 +01:00
|
|
|
#include <utils/VideoMode.h>
|
2015-01-24 23:42:22 +01:00
|
|
|
#include <utils/ImageResampler.h>
|
2016-07-12 00:53:48 +02:00
|
|
|
#include <utils/Logger.h>
|
2015-01-18 00:04:45 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// The FramebufferFrameGrabber is used for creating snapshots of the display (screenshots)
|
|
|
|
///
|
|
|
|
class FramebufferFrameGrabber
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
/// Construct a FramebufferFrameGrabber that will capture snapshots with specified dimensions.
|
|
|
|
///
|
|
|
|
/// @param[in] device The framebuffer device name/path
|
|
|
|
/// @param[in] width The width of the captured screenshot
|
|
|
|
/// @param[in] height The heigth of the captured screenshot
|
|
|
|
///
|
2017-03-04 22:17:42 +01:00
|
|
|
FramebufferFrameGrabber(const QString & device, const unsigned width, const unsigned height);
|
2015-01-18 00:04:45 +01:00
|
|
|
~FramebufferFrameGrabber();
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Set the video mode (2D/3D)
|
|
|
|
/// @param[in] mode The new video mode
|
|
|
|
///
|
|
|
|
void setVideoMode(const VideoMode videoMode);
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Captures a single snapshot of the display and writes the data to the given image. The
|
|
|
|
/// provided image should have the same dimensions as the configured values (_width and
|
|
|
|
/// _height)
|
|
|
|
///
|
|
|
|
/// @param[out] image The snapped screenshot (should be initialized with correct width and
|
|
|
|
/// height)
|
|
|
|
///
|
2015-01-24 23:42:22 +01:00
|
|
|
void grabFrame(Image<ColorRgb> & image);
|
2015-01-18 00:04:45 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
/// Framebuffer file descriptor
|
|
|
|
int _fbfd;
|
|
|
|
|
|
|
|
/// Pointer to framebuffer
|
|
|
|
unsigned char * _fbp;
|
|
|
|
|
|
|
|
/// Framebuffer device e.g. /dev/fb0
|
2017-03-04 22:17:42 +01:00
|
|
|
const QString _fbDevice;
|
2015-01-18 00:04:45 +01:00
|
|
|
|
|
|
|
/// With of the captured snapshot [pixels]
|
|
|
|
const unsigned _width;
|
|
|
|
|
|
|
|
/// Height of the captured snapshot [pixels]
|
|
|
|
const unsigned _height;
|
|
|
|
|
2015-01-24 23:42:22 +01:00
|
|
|
/// Image resampler for downscaling the image
|
|
|
|
ImageResampler * _imgResampler;
|
2016-07-12 00:53:48 +02:00
|
|
|
|
|
|
|
Logger * _log;
|
2015-01-18 00:04:45 +01:00
|
|
|
};
|