summaryrefslogtreecommitdiffhomepage
path: root/pose-widget/pose-widget.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-04-18 04:09:34 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-04-18 04:20:00 +0200
commit47a0d65019e0b3bbf3bad1935ff36c8eb1d9dc2c (patch)
tree2397c6b52bcc27d18edb5b132241f9119a2cfaaa /pose-widget/pose-widget.cpp
parent1d3ce15b2c73eac7c3ef0578007c1ba7c53a7ebe (diff)
pose-widget: also compute alpha in the loop
Diffstat (limited to 'pose-widget/pose-widget.cpp')
-rw-r--r--pose-widget/pose-widget.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/pose-widget/pose-widget.cpp b/pose-widget/pose-widget.cpp
index 24bf19cd..976bd981 100644
--- a/pose-widget/pose-widget.cpp
+++ b/pose-widget/pose-widget.cpp
@@ -318,30 +318,27 @@ void pose_transform::project_quad_texture()
const unsigned orig_pos__ = py * orig_pitch + px_ * orig_depth;
const unsigned orig_pos___ = py_ * orig_pitch + px * orig_depth;
- const uc a1 = orig[orig_pos + 3];
- const uc a2 = orig[orig_pos_ + 3];
- const uc a3 = orig[orig_pos__ + 3];
- const uc a4 = orig[orig_pos___ + 3];
-
// 1, 0 -- ax_, ay
// 0, 1 -- ax, ay_
// 1, 1 -- ax_, ay_
// 0, 0 -- ax, ay
- const uc alpha = (a1 * ax + a3 * ax_) * ay + (a4 * ax + a2 * ax_) * ay_;
+ //const uc alpha = (a1 * ax + a3 * ax_) * ay + (a4 * ax + a2 * ax_) * ay_;
const unsigned pos = y * dest_pitch + x * dest_depth;
- for (unsigned k = 0; k < 3; k++)
+ for (int k = 0; k < 4; k++)
{
const uc i = orig[orig_pos + k];
const uc i_ = orig[orig_pos_ + k];
const uc i__ = orig[orig_pos__ + k];
const uc i___ = orig[orig_pos___ + k];
- dest[pos + k] = unsigned((i * ax + i__ * ax_) * ay + (i___ * ax + i_ * ax_) * ay_)*alpha / 255;
+ dest[pos + k] = uc((i * ax + i__ * ax_) * ay + (i___ * ax + i_ * ax_) * ay_);
}
- dest[pos + 3] = alpha;
+ // premultiply alpha
+ for (int k = 0; k < 3; k++)
+ dest[pos + k] = (dest[pos+k]*num(dest[pos + 3]))/255;
}
}