Mercurial > octave-libtiff
changeset 31161:b731c8f6db95
Tiff: added setLibTIFFErrorsEnabled method to enable/disable LibTIFF errors
* Tiff.m: added PKG_ADD directive to disable errors at package load time.
* __tiff__.cc: added __tiff_set_errors_enabled__ function to enable or
disable LibTIFF error output.
author | magedrifaat <magedrifaat@gmail.com> |
---|---|
date | Wed, 10 Aug 2022 16:01:51 +0200 |
parents | 5f0c3da75926 |
children | 28817158ca86 |
files | libinterp/corefcn/__tiff__.cc scripts/io/Tiff.m |
diffstat | 2 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/__tiff__.cc Wed Aug 10 00:58:12 2022 +0200 +++ b/libinterp/corefcn/__tiff__.cc Wed Aug 10 16:01:51 2022 +0200 @@ -20,6 +20,7 @@ #if defined (HAVE_TIFF) # include <tiffio.h> +TIFFErrorHandler tiff_default_handler = NULL; #endif namespace octave @@ -2366,4 +2367,21 @@ #endif } + DEFUN (__tiff_set_errors_enabled__, args, , + "Enables or Disables error output from LibTIFF") + { +#if defined (HAVE_TIFF) + if (args (0).bool_value ()) + TIFFSetErrorHandler (tiff_default_handler); + else if (tiff_default_handler == NULL) + tiff_default_handler = TIFFSetErrorHandler (NULL); + else + TIFFSetErrorHandler (NULL); + + return octave_value_list (); +#else + err_disabled_feature ("setErrorEnabled", "Tiff"); +#endif + } + }
--- a/scripts/io/Tiff.m Wed Aug 10 00:58:12 2022 +0200 +++ b/scripts/io/Tiff.m Wed Aug 10 16:01:51 2022 +0200 @@ -1,3 +1,5 @@ +## PKG_ADD: __tiff_set_errors_enabled__ (false); + classdef Tiff < handle properties (Constant = true) TagID = struct ( @@ -97,6 +99,8 @@ "SGILog", 34676, "SGILog24", 34677, "JPEG2000", 34712, + # Not defined in LibTIFF, only in matlab + # TODO(maged): test these compression methods "JPEG2000_SVS_YCbCr", 33003, "JPEG2000_SVS_RGB", 33005 ); @@ -312,6 +316,10 @@ function versionString = getVersion() versionString = __tiff_version__ (); endfunction + + function setLibTIFFErrorsEnabled(state) + __tiff_set_errors_enabled__ (state); + endfunction endmethods endclassdef