@@ -74,3 +74,42 @@ TEST_CASE("name") {
7474 CHECK (axes.drawables ().size () == 2 );
7575}
7676
77+ TEST_CASE (" flip_image" ) {
78+ Axes axes;
79+ axes.setFixedAspectRatio ();
80+ axes.setXTight ();
81+ axes.setYTight ();
82+ axes.setTightBox ();
83+ axes.setMargins (0 , 0 , 0 , 0 );
84+
85+ cv::Mat1b mat = (cv::Mat1b (2 , 2 ) << 1 ,2 ,3 ,4 );
86+ auto & image = axes.create <Image>(mat);
87+ cv::Mat3b r = axes.render (2 , 2 );
88+
89+ auto check = [&](bool yReverse, bool widthNeg, bool heightNeg) {
90+ axes.setYReverse (yReverse);
91+ image.setPosition (cv::Rect2d (0 , 0 , widthNeg ? -2 : 2 , heightNeg ? -2 : 2 ));
92+ cv::Mat3b r = axes.render (2 , 2 );
93+ if ((!yReverse) != heightNeg) {
94+ cv::flip (r, r, 0 );
95+ }
96+ if (widthNeg) {
97+ cv::flip (r, r, 1 );
98+ }
99+ CHECK (r (0 , 0 )[0 ] == 1 );
100+ CHECK (r (0 , 1 )[0 ] == 2 );
101+ CHECK (r (1 , 0 )[0 ] == 3 );
102+ CHECK (r (1 , 1 )[0 ] == 4 );
103+ };
104+
105+ check (false , false , false );
106+ check (false , false , true );
107+ check (false , true , false );
108+ check (false , true , true );
109+ check (true , false , false );
110+ check (true , false , true );
111+ check (true , true , false );
112+ check (true , true , true );
113+ }
114+
115+
0 commit comments