comparison libgui/graphics/gl-select.cc @ 20554:7395fdd45d5f stable

Fix selection of one pixel high(wide) images (bug #46049) * gl-select.cc (opengl_selector::draw_image): make pixel size default to 1 when the corresponding image dimension is 1.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Sat, 26 Sep 2015 10:44:08 +0200
parents dc74b700cdec
children
comparison
equal deleted inserted replaced
20553:63d14a570039 20554:7395fdd45d5f
205 void 205 void
206 opengl_selector::draw_image (const image::properties& props) 206 opengl_selector::draw_image (const image::properties& props)
207 { 207 {
208 Matrix xd = props.get_xdata ().matrix_value (); 208 Matrix xd = props.get_xdata ().matrix_value ();
209 octave_idx_type nc = props.get_cdata ().columns (); 209 octave_idx_type nc = props.get_cdata ().columns ();
210 double x_pix_size = (xd(1) - xd(0)) / (nc - 1); 210 double x_pix_size = (nc == 1 ? 1 : (xd(1) - xd(0)) / (nc - 1));
211 211
212 Matrix yd = props.get_ydata ().matrix_value (); 212 Matrix yd = props.get_ydata ().matrix_value ();
213 octave_idx_type nr = props.get_cdata ().rows (); 213 octave_idx_type nr = props.get_cdata ().rows ();
214 double y_pix_size = (yd(1) - yd(0)) / (nr - 1); 214 double y_pix_size = (nr == 1 ? 1 : (yd(1) - yd(0)) / (nr - 1));
215 215
216 ColumnVector p1(3, 0.0), p2(3, 0.0), p3(3, 0.0), p4(3, 0.0); 216 ColumnVector p1(3, 0.0), p2(3, 0.0), p3(3, 0.0), p4(3, 0.0);
217 p1(0) = xd(0) - x_pix_size/2; 217 p1(0) = xd(0) - x_pix_size/2;
218 p1(1) = yd(0) - y_pix_size/2; 218 p1(1) = yd(0) - y_pix_size/2;
219 219