changeset 9682:c338cb954e58

adjust axis limits for images
author John W. Eaton <jwe@octave.org>
date Thu, 01 Oct 2009 15:10:14 -0400
parents 40775386ab58
children 5b3b9dcfd59c
files scripts/ChangeLog scripts/image/__img__.m src/ChangeLog src/gl-render.cc
diffstat 4 files changed, 26 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,7 @@
+2009-10-01  John W. Eaton  <jwe@octave.org>
+
+	* image/__img__.m: Adjust xlim and ylim correctly.
+
 2009-10-01  John W. Eaton  <jwe@octave.org>
 
 	* Makefile.in (plot/gnuplot_binary.m): New rule.
--- a/scripts/image/__img__.m
+++ b/scripts/image/__img__.m
@@ -49,14 +49,25 @@
     y = [1, rows(img)];
   endif
 
-  xlim = [x(1), x(end)];
-  ylim = [y(1), y(end)];
+  xdata = [x(1), x(end)];
+  ydata = [y(1), y(end)];
+
+  xlim = [x(1)-0.5, x(end)+0.5];
+  ylim = [y(1)-0.5, y(end)+0.5];
 
   ca = gca ();
 
-  tmp = __go_image__ (ca, "cdata", img, "xdata", xlim, "ydata", ylim, 
+  tmp = __go_image__ (ca, "cdata", img, "xdata", xdata, "ydata", ydata,
 		      "cdatamapping", "direct", varargin {:});
 
+  ## FIXME -- how can we do this and also get the {x,y}limmode
+  ## properties to remain "auto"?  I suppose this adjustment should
+  ## happen automatically in axes::update_axis_limits instead of
+  ## explicitly setting the values here.  But then what information is
+  ## available to axes::update_axis_limits to determine that the
+  ## adjustment is necessary?
+  set (ca, "xlim", xlim, "ylim", ylim);
+
   if (ndims (img) == 3)
     if (isinteger (img))
       c = class (img);
@@ -66,8 +77,7 @@
     endif
   endif
 
-  set (ca, "view", [0, 90], "xlimmode", "manual", "ylimmode", "manual",
-       "xlim", xlim, "ylim", ylim);
+  set (ca, "view", [0, 90]);
 
   if (strcmp (get (ca, "nextplot"), "replace"))
     set (ca, "ydir", "reverse");
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2009-10-01  John W. Eaton  <jwe@octave.org>
+
+	* gl-render.cc (opengl_renderer::draw (const image::properties&)):
+	Adjust origin for glRasterPos3d.
+
 2009-10-01  John W. Eaton  <jwe@octave.org>
 
 	* gl-render.cc: Style fixes.
--- a/src/gl-render.cc
+++ b/src/gl-render.cc
@@ -2704,8 +2704,8 @@
   const ColumnVector p0 = xform.transform (x(0), y(0), 0);
   const ColumnVector p1 = xform.transform (x(1), y(1), 0);
 
-  glPixelZoom ((p1(0)-p0(0))/(w-1) , -(p1(1)-p0(1))/(h-1));
-  glRasterPos3d (x(0), y(0), 0);
+  glPixelZoom ((p1(0)-p0(0))/(w-1), -(p1(1)-p0(1))/(h-1));
+  glRasterPos3d (x(0)-0.5, y(0)-0.5, 0);
 
   // Expect RGB data
   if (dv.length () == 3 && dv(2) == 3)