comparison libinterp/corefcn/__tiff__.cc @ 31200:4e8152ccc61a

libtinterp/corefcn/__tiff__.cc (set_field_data): fixed bug for ExtraSamples.
author magedrifaat <magedrifaat@gmail.com>
date Fri, 02 Sep 2022 03:41:05 +0200
parents 30b28458bb06
children e5e8cb049b4b
comparison
equal deleted inserted replaced
31199:30b28458bb06 31200:4e8152ccc61a
1603 if (! TIFFGetFieldDefaulted (tif, TIFFTAG_SAMPLESPERPIXEL, 1603 if (! TIFFGetFieldDefaulted (tif, TIFFTAG_SAMPLESPERPIXEL,
1604 &samples_per_pixel)) 1604 &samples_per_pixel))
1605 error ("Failed to obtain the number of samples per pixel"); 1605 error ("Failed to obtain the number of samples per pixel");
1606 1606
1607 uint16NDArray data_array = tag_ov.uint16_array_value (); 1607 uint16NDArray data_array = tag_ov.uint16_array_value ();
1608 // FIXME: this only works for RGB images. Need to handle grayscale, 1608
1609 // palette, cmyk and ycbcr 1609 if (data_array.numel () > samples_per_pixel)
1610 if (data_array.numel () > samples_per_pixel - 3)
1611 error ("Failed to set field, too many values"); 1610 error ("Failed to set field, too many values");
1612 1611
1613 if (! TIFFSetField (tif, tag_id, 1612 if (! TIFFSetField (tif, tag_id,
1614 static_cast<uint16_t> (data_array.numel ()), 1613 static_cast<uint16_t> (data_array.numel ()),
1615 data_array.data ())) 1614 data_array.data ()))