summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_ht/video_widget.cpp
blob: 01f2516a93095724b65da425c69e7518b6732379 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* Copyright (c) 2012 Patrick Ruoff
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 */

#include "video_widget.h"

#include <QDebug>

using namespace std;

void VideoWidget::update_image(unsigned char *frame, int width, int height)
{
    QMutexLocker((QMutex*)&mtx);
    QImage qframe = QImage(frame, width, height, 3 * width, QImage::Format_RGB888).rgbSwapped().mirrored();
    if (qframe.size() == size() || (qframe.width() <= this->width() && qframe.height() <= this->height()))
        qframe = qframe.mirrored();
    else
        qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation).mirrored();
    QPainter painter(&qframe);
    painter.setPen(Qt::blue);
    painter.setBrush(Qt::blue);
    pixmap = QPixmap::fromImage(qframe);
}