From 2afbfb1e417914565edb1c7ed14cc1ebf278672d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 29 Apr 2017 16:07:06 +0200 Subject: cv, pose-widget: don't premultiply alpha It doesn't improve perf. --- cv/video-widget.cpp | 2 +- pose-widget/pose-widget.cpp | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/cv/video-widget.cpp b/cv/video-widget.cpp index f4c16776..7d504f3a 100644 --- a/cv/video-widget.cpp +++ b/cv/video-widget.cpp @@ -54,7 +54,7 @@ void cv_video_widget::update_image(const cv::Mat& frame) const cv::Mat& img = *img_; - texture = QImage((const unsigned char*) img.data, w, h, QImage::Format_ARGB32_Premultiplied); + texture = QImage((const unsigned char*) img.data, w, h, QImage::Format_ARGB32); } } diff --git a/pose-widget/pose-widget.cpp b/pose-widget/pose-widget.cpp index aee2d628..4be3f09f 100644 --- a/pose-widget/pose-widget.cpp +++ b/pose-widget/pose-widget.cpp @@ -20,8 +20,8 @@ using namespace pose_widget_impl; pose_transform::pose_transform(QWidget* dst) : dst(dst), - image(w, h, QImage::Format_ARGB32_Premultiplied), - image2(w, h, QImage::Format_ARGB32_Premultiplied), + image(w, h, QImage::Format_ARGB32), + image2(w, h, QImage::Format_ARGB32), width(w), height(h), fresh(false) { @@ -303,11 +303,6 @@ void pose_transform::project_quad_texture() using uc = unsigned char; - const float ax_ = fx - unsigned(fx); - const float ay_ = fy - unsigned(fy); - const float ax = 1 - ax_; - const float ay = 1 - ay_; - const unsigned px_ = fx + 1; const unsigned py_ = fy + 1; const unsigned px = fx; @@ -324,6 +319,11 @@ void pose_transform::project_quad_texture() // 0, 0 -- ax, ay //const uc alpha = (a1 * ax + a3 * ax_) * ay + (a4 * ax + a2 * ax_) * ay_; + const float ax_ = fx - unsigned(fx); + const float ay_ = fy - unsigned(fy); + const float ax = 1 - ax_; + const float ay = 1 - ay_; + const unsigned pos = y * dest_pitch + x * dest_depth; for (int k = 0; k < 4; k++) @@ -335,10 +335,6 @@ void pose_transform::project_quad_texture() dest[pos + k] = uc((i * ax + i__ * ax_) * ay + (i___ * ax + i_ * ax_) * ay_); } - - // premultiply alpha - for (int k = 0; k < 3; k++) - dest[pos + k] = (dest[pos+k]*num(dest[pos + 3]))/255; } } -- cgit v1.2.3