diff --git a/c++/perspective/src/mainwindow.cpp b/c++/perspective/src/mainwindow.cpp index 6537032..fce4a8b 100644 --- a/c++/perspective/src/mainwindow.cpp +++ b/c++/perspective/src/mainwindow.cpp @@ -121,7 +121,12 @@ MainWindow::update_dst_surface() { std::cout << "update_dst_surface() - begin" << std::endl; dst_surface.clear(); - + + // full dst_bounds + const IntPair2 full_dst_bounds_pixels( + IntVector2(0, 0), + IntVector2(src_view.get_width(), src_view.get_height()) ); + // src matrix const Pair2 src_bounds( src_rect_p0->position, @@ -182,8 +187,12 @@ MainWindow::update_dst_surface() { Perspective::print_layers(layers, Log::tab(2)); std::cout << Log::tab() << "---------------" << std::endl; + // override dst_bounds + for(Perspective::LayerList::iterator i = layers.begin(); i != layers.end(); ++i) + i->dst_bounds = full_dst_bounds_pixels; + // make surface - DataSurface surface(dst_bounds_pixels.p1.x, dst_bounds_pixels.p1.y); + DataSurface surface(full_dst_bounds_pixels.p1.x, full_dst_bounds_pixels.p1.y); for(Perspective::LayerList::const_iterator i = layers.begin(); i != layers.end(); ++i) { DataSurface layer_surface(i->src_size.x, i->src_size.y); generator.generate(layer_surface, i->src_bounds); diff --git a/c++/perspective/src/perspective.cpp b/c++/perspective/src/perspective.cpp index 51a9438..fff728f 100644 --- a/c++/perspective/src/perspective.cpp +++ b/c++/perspective/src/perspective.cpp @@ -178,10 +178,6 @@ Perspective::make_alpha_matrix( Real bw0, Real bw1, const Vector3 &w_col ) { - return Matrix3( - Vector3( 0, 0, 0 ), - Vector3( 0, 0, 0 ), - Vector3( 1, 1, 1 ) ); const Vector3 a_col = make_alpha_matrix_col(aw0, aw1, w_col); const Vector3 b_col = make_alpha_matrix_col(bw0, bw1, w_col); return Matrix3( @@ -359,13 +355,13 @@ Perspective::create_layers( } } Vector2 line[2]; - int line_count = truncate_line(line, Pair2(dst_bounds), A, B, 1/w0 - C); + int line_count = truncate_line(line, Pair2(dst_bounds), A, B, C - 1/w0); for(int j = 0; j < line_count; ++j) { layer_src_bounds.expand( (back_matrix * Vector3(line[j], 1)).vec2() * w0 ); layer_dst_bounds.expand( line[j] ); } - line_count = truncate_line(line, Pair2(dst_bounds), A, B, 1/w1 - C); + line_count = truncate_line(line, Pair2(dst_bounds), A, B, C - 1/w1); for(int j = 0; j < line_count; ++j) { layer_src_bounds.expand( (back_matrix * Vector3(line[j], 1)).vec2() * w1 ); layer_dst_bounds.expand( line[j] ); @@ -390,7 +386,7 @@ Perspective::create_layers( Vector2(layer.dst_bounds.size()) ); layer.back_matrix *= back_matrix; layer.back_alpha_matrix = make_alpha_matrix( - aw0, aw1, bw0, bw1, + 1/aw0, 1/aw1, 1/bw0, 1/bw1, layer.back_matrix.get_col(2) ); out_layers.push_back(layer); }