Mercurial > octave-libtiff
changeset 31117:530dbd1d6b07
Tiff getTag: fixed bug for multivalued tags where only first item is returned
* __tiff__.cc(get_field_data): fixed bug for multivalued tags where only
the first element is returned.
author | magedrifaat <magedrifaat@gmail.com> |
---|---|
date | Sat, 16 Jul 2022 23:40:15 +0200 |
parents | 9b3685afb4e7 |
children | f8be3654caef |
files | libinterp/dldfcn/__tiff__.cc |
diffstat | 1 files changed, 29 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/dldfcn/__tiff__.cc Sat Jul 16 21:02:07 2022 +0200 +++ b/libinterp/dldfcn/__tiff__.cc Sat Jul 16 23:40:15 2022 +0200 @@ -438,10 +438,10 @@ return interpret_tag_data (data, array_size, TIFFFieldDataType (fip)); } - octave_value_list + octave_value get_field_data (TIFF *tif, const TIFFField *fip) { - octave_value_list tag_data_ovl (1); + octave_value tag_data_ov; uint32_t tag_id = TIFFFieldTag (fip); // TODO(maged): find/create images to test the special tags @@ -449,18 +449,18 @@ { case TIFFTAG_STRIPBYTECOUNTS: case TIFFTAG_STRIPOFFSETS: - tag_data_ovl = get_array_field_data (tif, fip, + tag_data_ov = get_array_field_data (tif, fip, TIFFNumberOfStrips (tif)); break; case TIFFTAG_TILEBYTECOUNTS: case TIFFTAG_TILEOFFSETS: - tag_data_ovl = get_array_field_data (tif, fip, TIFFNumberOfTiles (tif)); + tag_data_ov = get_array_field_data (tif, fip, TIFFNumberOfTiles (tif)); break; case TIFFTAG_YCBCRCOEFFICIENTS: - tag_data_ovl = get_array_field_data (tif, fip, 3); + tag_data_ov = get_array_field_data (tif, fip, 3); break; case TIFFTAG_REFERENCEBLACKWHITE: - tag_data_ovl = get_array_field_data (tif, fip, 6); + tag_data_ov = get_array_field_data (tif, fip, 6); break; case TIFFTAG_GRAYRESPONSECURVE: { @@ -468,7 +468,7 @@ if (! TIFFGetField (tif, TIFFTAG_BITSPERSAMPLE, &bits_per_sample)) error ("Failed to obtain the bit depth"); - tag_data_ovl = get_array_field_data (tif, fip, 1<<bits_per_sample); + tag_data_ov = get_array_field_data (tif, fip, 1<<bits_per_sample); break; } case TIFFTAG_COLORMAP: @@ -509,7 +509,7 @@ out_ptr += count; memcpy (out_ptr, blue_array.fortran_vec (), sizeof(uint16_t) * count); - tag_data_ovl(0) = octave_value (mat_out); + tag_data_ov = octave_value (mat_out); break; } case TIFFTAG_TRANSFERFUNCTION: @@ -527,8 +527,8 @@ if (samples_per_pixel == 1) { validate_tiff_get_field (TIFFGetField (tif, TIFFTAG_COLORMAP, &ch1)); - tag_data_ovl(0) - = interpret_tag_data (ch1, count, TIFFFieldDataType (fip)); + tag_data_ov = interpret_tag_data (ch1, count, + TIFFFieldDataType (fip)); } else { @@ -557,7 +557,7 @@ out_ptr += count; memcpy (out_ptr, ch3_array.fortran_vec (), sizeof(uint16_t) * count); - tag_data_ovl(0) = octave_value (mat_out); + tag_data_ov = octave_value (mat_out); } break; } @@ -570,10 +570,16 @@ uint16_t tag_part1, tag_part2; validate_tiff_get_field (TIFFGetField (tif, tag_id, &tag_part1, &tag_part2)); - tag_data_ovl(0) - = interpret_tag_data (&tag_part1, 1, TIFFFieldDataType (fip)); - tag_data_ovl(1) - = interpret_tag_data (&tag_part2, 1, TIFFFieldDataType (fip)); + + Matrix mat_out (1, 2); + mat_out(0) + = interpret_tag_data (&tag_part1, 1, + TIFFFieldDataType (fip)).double_value (); + mat_out(1) + = interpret_tag_data (&tag_part2, 1, + TIFFFieldDataType (fip)).double_value (); + + tag_data_ov = octave_value (mat_out); break; } case TIFFTAG_SUBIFD: @@ -581,8 +587,8 @@ uint16_t count; uint64_t *offsets; validate_tiff_get_field (TIFFGetField (tif, tag_id, &count, &offsets)); - tag_data_ovl(0) = interpret_tag_data (offsets, count, - TIFFFieldDataType (fip)); + tag_data_ov = interpret_tag_data (offsets, count, + TIFFFieldDataType (fip)); break; } case TIFFTAG_EXTRASAMPLES: @@ -590,8 +596,8 @@ uint16_t count; uint16_t *types; validate_tiff_get_field (TIFFGetField (tif, tag_id, &count, &types)); - tag_data_ovl(0) = interpret_tag_data (types, count, - TIFFFieldDataType (fip)); + tag_data_ov = interpret_tag_data (types, count, + TIFFFieldDataType (fip)); break; } // TODO(maged): These tags are more complex to implement @@ -610,14 +616,14 @@ case TIFFTAG_SGILOGDATAFMT: case TIFFTAG_GRAYRESPONSEUNIT: { - tag_data_ovl = get_scalar_field_data (tif, fip); + tag_data_ov = get_scalar_field_data (tif, fip); break; } default: - tag_data_ovl = get_scalar_field_data (tif, fip); + tag_data_ov = get_scalar_field_data (tif, fip); } - return tag_data_ovl; + return tag_data_ov; } #endif @@ -708,10 +714,7 @@ error ("Tiff tag not found"); } - - octave_value_list tag_data_ovl = get_field_data (tif, fip); - - return tag_data_ovl; + return octave_value_list (get_field_data (tif, fip)); #else err_disabled_feature ("getTag", "Tiff"); #endif