diff src/graphics.cc @ 11076:b748b86cb8c1

fix images with width or height of 1
author Shai Ayal <shaiay@users.sourceforge.net>
date Mon, 04 Oct 2010 21:35:02 +0200
parents 8a3b7e8fcbbc
children f0e9befd6a1c
line wrap: on
line diff
--- a/src/graphics.cc
+++ b/src/graphics.cc
@@ -6227,6 +6227,45 @@
   return retval;
 }
 
+DEFUN (__image_pixel_size__, args, ,
+   "-*- texinfo -*-\n\
+@deftypefn  {Built-in Function} {@var{px},@var{py}} __image_pixel_size__ (@var{h})\n\
+Internal function: returns the pixel size of the image in normalized units.\n\
+@end deftypefn")
+{
+  octave_value retval;
+
+  int nargin = args.length ();
+
+  if (nargin == 1)
+    {
+      double h = args(0).double_value ();
+
+      if (! error_state)
+        {
+          graphics_object fobj = gh_manager::get_object (h);
+          if (fobj &&  fobj.isa ("image"))
+            {
+              image::properties& ip =
+                dynamic_cast<image::properties&> (fobj.get_properties ());
+              
+              Matrix dp =  Matrix (1, 2, 0);
+              dp(0, 0) = ip.pixel_xsize ();
+              dp(0, 1) = ip.pixel_ysize ();
+              retval = dp;
+            }
+          else
+            error ("__image_pixel_size__: object is not an image");
+        }
+      else
+        error ("__image_pixel_size__: argument is not a handle");
+    }
+  else
+    print_usage ();
+
+  return retval;
+}
+
 DEFUN (available_backends, , ,
    "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} available_backends ()\n\