# HG changeset patch # User magedrifaat # Date 1658692405 -7200 # Node ID dfab9c6982bf6583e0a755639155238a06cca974 # Parent 524cb3106432f52fb19db078efdb4eb8a49626dd Tiff getTag: added support for single quotes string fo the tag name * __tiff__.cc(F_tiff_get_tag, F__tiff_set_tag): added support for single quotes string for the tag name. diff -r 524cb3106432 -r dfab9c6982bf libinterp/dldfcn/__tiff__.cc --- a/libinterp/dldfcn/__tiff__.cc Sun Jul 24 21:21:11 2022 +0200 +++ b/libinterp/dldfcn/__tiff__.cc Sun Jul 24 21:53:25 2022 +0200 @@ -114,7 +114,6 @@ for (uint32_t strip = 0; strip < strip_count; strip++) { // Read the strip data into the matrix directly - // TODO(maged): Are incorrect sized strips checked internally? strip_size = TIFFReadEncodedStrip (tif, strip, img_fvec, -1); // Check if the strip read failed. @@ -123,6 +122,7 @@ // Check if the size being read exceeds the bounds of the matrix // In case of a corrupt image with more data than needed + // This is probably redundant as LibTIFF checks sizes internally if (written_size + strip_size > image_size) error ("Strip data is larger than the image size"); @@ -626,7 +626,7 @@ case TIFF_IFD: case TIFF_IFD8: // TODO(maged): implement IFD datatype? - error ("Unimplemented IFFD data type"); + error ("Unimplemented IFD data type"); break; default: error ("Unsupported tag data type"); @@ -649,11 +649,10 @@ error ("Unsupported tag"); int type_size = TIFFDataWidth (TIFFFieldDataType (fip)); - // TODO(maged): use shared pointer instead of malloc + void *data = _TIFFmalloc (type_size); - // TODO(maged): check if this should be GetFieldDefaulted instead - validate_tiff_get_field (TIFFGetField (tif, tag_id, data), data); - octave_value tag_data_ov = interpret_tag_data (data, 1, + validate_tiff_get_field (TIFFGetFieldDefaulted (tif, tag_id, data), data); + octave_value tag_data_ov = interpret_tag_data (data,TODO 1, TIFFFieldDataType (fip)); _TIFFfree (data); @@ -975,7 +974,6 @@ std::string filename = args (0).string_value (); std::string mode = "r"; - // TODO(maged): check valid mode if (nargin == 2) mode = args (1).string_value (); @@ -990,7 +988,6 @@ error ("Invalid mode for openning Tiff file: %s", mode.c_str ()); } - // TODO(maged): Look into unwind action TIFF *tif = TIFFOpen (filename.c_str (), mode.c_str ()); if (! tif) @@ -1041,8 +1038,9 @@ uint32_t tag_id; const TIFFField *fip; - // TODO(maged): support sq_string as well - if (args (1).type_name () == "string") + + if (args (1).type_name () == "string" + || args (1).type_name () == "sq_string") { std::string tagName = args (1).string_value (); fip = TIFFFieldWithName (tif, tagName.c_str ()); @@ -1055,7 +1053,7 @@ { tag_id = args (1).int_value (); fip = TIFFFieldWithTag (tif, tag_id); - // TODO(maged): Handle other types of errors (e.g. unsupported tags) + if (! fip) error ("Tiff tag not found"); } @@ -1085,8 +1083,9 @@ else { const TIFFField *fip; - // TODO(maged): support sq_string as well - if (args (1).type_name () == "string") + + if (args (1).type_name () == "string" + || args(1).type_name () == "sq_string") { std::string tagName = args (1).string_value (); fip = TIFFFieldWithName (tif, tagName.c_str ());