Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit ea4c1a6

Browse files
committed
Create an Hyperion image
1 parent 87b8910 commit ea4c1a6

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

test/v4l2_to_png/V4L2Grabber.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,7 @@ void V4L2Grabber::process_image(const uint8_t * data)
593593
int width = (_width + _pixelDecimation/2) / _pixelDecimation;
594594
int height = (_height + _pixelDecimation/2) / _pixelDecimation;
595595

596-
597-
QImage image(width, height, QImage::Format_RGB888);
596+
Image<ColorRgb> image(width, height);
598597

599598
for (int ySource = _pixelDecimation/2, yDest = 0; ySource < _height; ySource += _pixelDecimation, ++yDest)
600599
{
@@ -605,14 +604,14 @@ void V4L2Grabber::process_image(const uint8_t * data)
605604
uint8_t u = (xSource%2 == 0) ? data[index] : data[index-2];
606605
uint8_t v = (xSource%2 == 0) ? data[index+2] : data[index];
607606

608-
uint8_t r, g, b;
609-
yuv2rgb(y, u, v, r, g, b);
610-
611-
image.setPixel(xDest, yDest, qRgb(r, g, b));
607+
ColorRgb & rgb = image(xDest, yDest);
608+
yuv2rgb(y, u, v, rgb.red, rgb.green, rgb.blue);
612609
}
613610
}
614611

615-
image.save("screenshot.png");
612+
// store as PNG
613+
QImage pngImage((const uint8_t *) image.memptr(), width, height, 3*width, QImage::Format_RGB888);
614+
pngImage.save("screenshot.png");
616615
}
617616

618617
int V4L2Grabber::xioctl(int request, void *arg)

test/v4l2_to_png/V4L2Grabber.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#include <string>
55
#include <vector>
66

7+
// util includes
8+
#include <utils/Image.h>
9+
#include <utils/ColorRgb.h>
10+
711
/// Capture class for V4L2 devices
812
///
913
/// @see http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html

0 commit comments

Comments
 (0)