Mercurial > octave
changeset 22369:17c9cc85842e
Fix display of scaled images in OpenGL toolkits (bug #48879).
* gl-render.cc (draw_image): Adjust spacing and wrap long lines,
for readability.
* graphics.cc (convert_cdata_2): Use 'fix' rather than 'round'
when scaling data to climits.
* imagesc.m: Add %!demo to test display.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 23 Aug 2016 16:13:31 -0700 |
parents | 3dc8764e3bd5 |
children | 0a2961d5893c |
files | libinterp/corefcn/gl-render.cc libinterp/corefcn/graphics.cc scripts/image/imagesc.m |
diffstat | 3 files changed, 15 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/gl-render.cc Tue Aug 23 16:09:56 2016 -0700 +++ b/libinterp/corefcn/gl-render.cc Tue Aug 23 16:13:31 2016 -0700 @@ -3212,7 +3212,7 @@ Matrix x = props.get_xdata ().matrix_value (); Matrix y = props.get_ydata ().matrix_value (); - // Someone wants us to draw an empty image? No way. + // Someone wants us to draw an empty image? No way. if (x.is_empty () || y.is_empty ()) return; @@ -3225,7 +3225,8 @@ const ColumnVector p0 = xform.transform (x(0), y(0), 0); const ColumnVector p1 = xform.transform (x(1), y(1), 0); - if (octave::math::isnan (p0(0)) || octave::math::isnan (p0(1)) || octave::math::isnan (p1(0)) || octave::math::isnan (p1(1))) + if (octave::math::isnan (p0(0)) || octave::math::isnan (p0(1)) + || octave::math::isnan (p1(0)) || octave::math::isnan (p1(1))) { warning ("opengl_renderer: image X,Y data too large to draw"); return; @@ -3238,8 +3239,8 @@ if (w > 1) { - pix_dx = (p1(0) - p0(0))/(w-1); - nor_dx = (x(1) - x(0))/(w-1); + pix_dx = (p1(0) - p0(0)) / (w-1); + nor_dx = (x(1) - x(0)) / (w-1); } else { @@ -3250,8 +3251,8 @@ if (h > 1) { - pix_dy = (p1(1) - p0(1))/(h-1); - nor_dy = (y(1) - y(0))/(h-1); + pix_dy = (p1(1) - p0(1)) / (h-1); + nor_dy = (y(1) - y(0)) / (h-1); } else { @@ -3288,7 +3289,6 @@ GLfloat vp[4]; glGetFloatv (GL_VIEWPORT, vp); // FIXME: actually add the code to do it! - } if (i0 >= i1 || j0 >= j1)
--- a/libinterp/corefcn/graphics.cc Tue Aug 23 16:09:56 2016 -0700 +++ b/libinterp/corefcn/graphics.cc Tue Aug 23 16:13:31 2016 -0700 @@ -852,7 +852,7 @@ octave_idx_type nc, octave_idx_type i, double *av) { if (is_scaled) - x = octave::math::round ((nc - 1) * (x - clim_0) / (clim_1 - clim_0)); + x = octave::math::fix (nc * (x - clim_0) / (clim_1 - clim_0)); else if (is_real) x = octave::math::round (x - 1);
--- a/scripts/image/imagesc.m Tue Aug 23 16:09:56 2016 -0700 +++ b/scripts/image/imagesc.m Tue Aug 23 16:13:31 2016 -0700 @@ -181,3 +181,10 @@ %! hold off; %! title ("line, image, line, image, line w/hold()"); +%!demo # bug #48879 +%! clf; +%! img = reshape (1:100, 10, 10); +%! imagesc (img); +%! colormap (prism (10)); +%! title ("10 vertical color bars"); +