diff libinterp/corefcn/__tiff__.cc @ 31197:1604c8812b67

Tiff: added numberOfDirectories method.
author magedrifaat <magedrifaat@gmail.com>
date Thu, 01 Sep 2022 01:56:20 +0200
parents 1da6d747bf78
children 93eb0d6e7f62
line wrap: on
line diff
--- a/libinterp/corefcn/__tiff__.cc	Thu Sep 01 00:10:37 2022 +0200
+++ b/libinterp/corefcn/__tiff__.cc	Thu Sep 01 01:56:20 2022 +0200
@@ -129,12 +129,6 @@
   }
 
   bool
-  is_numeric_scalar (octave_value ov)
-  {
-    return ov.isnumeric () && ov.isreal () && ov.is_scalar_type ();
-  }
-
-  bool
   is_colormap (octave_value ov)
   {
     return ov.isnumeric () && ov.isreal () && ov.isfloat ()
@@ -3188,6 +3182,30 @@
 #endif
   }
 
+  DEFUN (__tiff_number_of_directories__, args, ,
+             "Get the number of tiles in the image")
+  {
+#if defined (HAVE_TIFF)
+    int nargin = args.length ();
+
+    if (nargin == 0)
+      error ("No handle provided\n");
+    
+    octave_tiff_handle *tiff_handle
+      = octave_tiff_handle::get_tiff_handle (args(0));
+    check_closed (tiff_handle);
+
+    set_internal_handlers ();
+
+    TIFF *tif = tiff_handle->get_file ();
+    
+    double dir_count = static_cast<double> (TIFFNumberOfDirectories (tif));
+    return ovl (dir_count);
+#else
+    err_disabled_feature ("numberOfDirectories", "Tiff");
+#endif
+  }
+
   DEFUN (__tiff_compute_strip__, args, ,
              "Get the strip index containing the given row")
   {