summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_ht/ht_video_widget.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-10-22 02:40:02 +0200
committerStanislaw Halik <sthalik@misaki.pl>2013-10-22 02:40:02 +0200
commit8503f538d18f8df0f18ee4973e96f3889a11419a (patch)
treecc7c65a8911ed7f897070d9c9898506c9a414a74 /ftnoir_tracker_ht/ht_video_widget.cpp
parentd7d733131d62777481c9a72fee9005dd58cf0c74 (diff)
optimize HT widget refresh
Signed-off-by: Stanislaw Halik <sthalik@misaki.pl>
Diffstat (limited to 'ftnoir_tracker_ht/ht_video_widget.cpp')
-rw-r--r--ftnoir_tracker_ht/ht_video_widget.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/ftnoir_tracker_ht/ht_video_widget.cpp b/ftnoir_tracker_ht/ht_video_widget.cpp
index 4d7d66a2..8ccec997 100644
--- a/ftnoir_tracker_ht/ht_video_widget.cpp
+++ b/ftnoir_tracker_ht/ht_video_widget.cpp
@@ -14,17 +14,31 @@ using namespace std;
void HTVideoWidget::update_image(unsigned char *frame, int width, int height)
{
QMutexLocker foo(&mtx);
+ memcpy(fb, frame, width * height * 3);
+ this->width = width;
+ this->height = height;
+}
+
+void HTVideoWidget::update_and_repaint()
+{
+ QMutexLocker foo(&mtx);
+ if (width*height <= 0)
+ return;
QImage qframe = QImage(width, height, QImage::Format_RGB888);
uchar* data = qframe.bits();
const int pitch = qframe.bytesPerLine();
for (int y = 0; y < height; y++)
+ {
+ const int part = y*width;
for (int x = 0; x < width; x++)
{
- const int pos = 3 * (y*width + x);
- data[y * pitch + x * 3 + 0] = frame[pos + 2];
- data[y * pitch + x * 3 + 1] = frame[pos + 1];
- data[y * pitch + x * 3 + 2] = frame[pos + 0];
+ const int pos = 3 * (part + x);
+ data[y * pitch + x * 3 + 0] = fb[pos + 2];
+ data[y * pitch + x * 3 + 1] = fb[pos + 1];
+ data[y * pitch + x * 3 + 2] = fb[pos + 0];
}
- qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation);
- pixmap = QPixmap::fromImage(qframe);
+ }
+ auto qframe2 = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation);
+ pixmap = QPixmap::fromImage(qframe2);
+ update();
}