Mercurial > octave-libtiff
comparison libinterp/dldfcn/__tiff__.cc @ 31104:b5d59c115e52
Use HAVE_TIFF flag to optionally disable Tiff
* __tiff__.cc: Used the HAVE_TIFF flag to disable the internal functions of Tiff.
author | magedrifaat <magedrifaat@gmail.com> |
---|---|
date | Sun, 03 Jul 2022 23:53:44 +0200 |
parents | 76b21bed2920 |
children | 7c5b8a294f60 |
comparison
equal
deleted
inserted
replaced
31103:76b21bed2920 | 31104:b5d59c115e52 |
---|---|
1 #if defined (HAVE_CONFIG_H) | |
2 # include "config.h" | |
3 #endif | |
4 | |
1 #include <string> | 5 #include <string> |
2 #include <iostream> | 6 #include <iostream> |
3 | 7 |
4 #include "defun-dld.h" | 8 #include "defun-dld.h" |
5 #include "ov.h" | 9 #include "ov.h" |
6 #include "ovl.h" | 10 #include "ovl.h" |
7 #include "error.h" | 11 #include "error.h" |
8 | 12 |
9 #include <tiffio.h> | 13 #include "errwarn.h" |
14 | |
15 #if defined (HAVE_TIFF) | |
16 # include <tiffio.h> | |
17 #endif | |
10 | 18 |
11 // TODO(maged): Tidy up the formatting to be consistant with octave | 19 // TODO(maged): Tidy up the formatting to be consistant with octave |
12 | 20 |
13 namespace octve | 21 namespace octve |
14 { | 22 { |
23 #if defined (HAVE_TIFF) | |
15 // Error if status is not 1 (success status for TIFFGetField) | 24 // Error if status is not 1 (success status for TIFFGetField) |
16 void | 25 void |
17 validate_tiff_get_field (bool status, void *p_to_free=NULL) | 26 validate_tiff_get_field (bool status, void *p_to_free=NULL) |
18 { | 27 { |
19 if (status != 1) | 28 if (status != 1) |
345 tag_data_ovl = get_scalar_field_data (tif, fip); | 354 tag_data_ovl = get_scalar_field_data (tif, fip); |
346 } | 355 } |
347 | 356 |
348 return tag_data_ovl; | 357 return tag_data_ovl; |
349 } | 358 } |
359 #endif | |
350 | 360 |
351 DEFUN_DLD (__open_tiff__, args, nargout, | 361 DEFUN_DLD (__open_tiff__, args, nargout, |
352 "Open a Tiff file and return its handle") | 362 "Open a Tiff file and return its handle") |
353 { | 363 { |
364 #if defined (HAVE_TIFF) | |
354 int nargin = args.length (); | 365 int nargin = args.length (); |
355 | 366 |
356 if (nargin == 0 || nargin > 2) | 367 if (nargin == 0 || nargin > 2) |
357 { | 368 { |
358 // TODO(maged): return invalid object instead?? | 369 // TODO(maged): return invalid object instead?? |
373 error ("Failed to open Tiff file\n"); | 384 error ("Failed to open Tiff file\n"); |
374 | 385 |
375 // TODO(maged): use inheritance of octave_base_value instead | 386 // TODO(maged): use inheritance of octave_base_value instead |
376 octave_value tiff_ov = octave_value ((uint64_t)tif); | 387 octave_value tiff_ov = octave_value ((uint64_t)tif); |
377 return octave_value_list (tiff_ov); | 388 return octave_value_list (tiff_ov); |
389 #else | |
390 err_disabled_feature ("Tiff", "Tiff"); | |
391 #endif | |
378 } | 392 } |
379 | 393 |
380 | 394 |
381 DEFUN_DLD (__close_tiff__, args, nargout, | 395 DEFUN_DLD (__close_tiff__, args, nargout, |
382 "Close a tiff file") | 396 "Close a tiff file") |
383 { | 397 { |
398 #if defined (HAVE_TIFF) | |
384 int nargin = args.length (); | 399 int nargin = args.length (); |
385 | 400 |
386 if (nargin == 0) | 401 if (nargin == 0) |
387 error ("No handle provided\n"); | 402 error ("No handle provided\n"); |
388 | 403 |
389 TIFF *tif = (TIFF *)(args (0).uint64_value ()); | 404 TIFF *tif = (TIFF *)(args (0).uint64_value ()); |
390 TIFFClose (tif); | 405 TIFFClose (tif); |
391 | 406 |
392 return octave_value_list (); | 407 return octave_value_list (); |
408 #else | |
409 err_disabled_feature ("close", "Tiff"); | |
410 #endif | |
393 } | 411 } |
394 | 412 |
395 | 413 |
396 DEFUN_DLD (__tiff_get_tag__, args, nargout, | 414 DEFUN_DLD (__tiff_get_tag__, args, nargout, |
397 "Get the value of a tag from a tiff image") | 415 "Get the value of a tag from a tiff image") |
398 { | 416 { |
417 #if defined (HAVE_TIFF) | |
399 int nargin = args.length (); | 418 int nargin = args.length (); |
400 | 419 |
401 if (nargin == 0) | 420 if (nargin == 0) |
402 error ("No handle provided\n"); | 421 error ("No handle provided\n"); |
403 | 422 |
428 | 447 |
429 | 448 |
430 octave_value_list tag_data_ovl = get_field_data (tif, fip); | 449 octave_value_list tag_data_ovl = get_field_data (tif, fip); |
431 | 450 |
432 return tag_data_ovl; | 451 return tag_data_ovl; |
452 #else | |
453 err_disabled_feature ("getTag", "Tiff"); | |
454 #endif | |
433 } | 455 } |
434 } | 456 } |