2013-08-15 21:11:02 +02:00
|
|
|
|
|
|
|
// STL includes
|
|
|
|
#include <csignal>
|
|
|
|
|
|
|
|
// QT includes
|
|
|
|
#include <QImage>
|
|
|
|
#include <QTest>
|
|
|
|
|
2013-08-17 16:12:42 +02:00
|
|
|
// Dispmanx grabber includes
|
|
|
|
#include <dispmanx-grabber/DispmanxFrameGrabber.h>
|
2013-08-15 21:11:02 +02:00
|
|
|
|
|
|
|
static bool running = true;
|
|
|
|
|
|
|
|
void signal_handler(int signum)
|
|
|
|
{
|
|
|
|
running = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
signal(SIGTERM, signal_handler);
|
|
|
|
signal(SIGINT, signal_handler);
|
|
|
|
|
|
|
|
DispmanxFrameGrabber frameGrabber(64, 64);
|
2013-11-11 10:00:37 +01:00
|
|
|
frameGrabber.setFlags(DISPMANX_SNAPSHOT_NO_RGB|DISPMANX_SNAPSHOT_FILL);
|
2013-08-15 21:11:02 +02:00
|
|
|
|
|
|
|
unsigned iFrame = 0;
|
2013-11-11 10:00:37 +01:00
|
|
|
QImage qImage(64, 64, QImage::Format_ARGB32);
|
|
|
|
Image<ColorRgba> imageRgba(64, 64);
|
2013-08-15 21:11:02 +02:00
|
|
|
|
|
|
|
while(running)
|
|
|
|
{
|
2013-11-11 10:00:37 +01:00
|
|
|
frameGrabber.grabFrame(imageRgba);
|
2013-08-15 21:11:02 +02:00
|
|
|
|
|
|
|
for (int iScanline=0; iScanline<qImage.height(); ++iScanline)
|
|
|
|
{
|
|
|
|
unsigned char* scanLinePtr = qImage.scanLine(iScanline);
|
2013-11-11 10:00:37 +01:00
|
|
|
memcpy(scanLinePtr, imageRgba.memptr()+imageRgba.width()*iScanline, imageRgba.width()*sizeof(ColorRgba));
|
2013-08-15 21:11:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
qImage.save(QString("HYPERION_%3.png").arg(iFrame));
|
|
|
|
++iFrame;
|
|
|
|
|
|
|
|
QTest::qSleep(1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|