Mercurial > octave-libtiff
diff libinterp/dldfcn/__tiff__.cc @ 31145:2e11f9cb30b8
Tiff writeEncodedStrip: added warning for input data larger than the size of the strip.
author | magedrifaat <magedrifaat@gmail.com> |
---|---|
date | Sun, 31 Jul 2022 03:55:42 +0200 |
parents | 8ba9f2326ee9 |
children | 50402b8dfb4a |
line wrap: on
line diff
--- a/libinterp/dldfcn/__tiff__.cc Sun Jul 31 01:26:02 2022 +0200 +++ b/libinterp/dldfcn/__tiff__.cc Sun Jul 31 03:55:42 2022 +0200 @@ -932,12 +932,33 @@ } else error ("Planar configuration not supported"); + + if (strip_data.dim1 () > rows_in_strip) + warning ("The strip is composed of %ld rows but the input has %ld rows.", + rows_in_strip, + strip_data.dim1 ()); - // TODO(maged): give a warning for a larger input strip + if (strip_data.dim2 () > image_data->width) + warning ("The image width is %ld but the input has %ld columns.", + image_data->width, + strip_data.dim2 ()); + + if (strip_data.ndims () > 2) + { + if (image_data->planar_configuration == PLANARCONFIG_CONTIG + && strip_data.dim3 () > image_data->samples_per_pixel) + warning ("The strip is composed of %ld channels but the input has %ld channels.", + image_data->samples_per_pixel, + strip_data.dim3 ()); + else if (image_data->planar_configuration == PLANARCONFIG_SEPARATE + && strip_data.dim3 () > 1) + warning ("The strip is composed of %ld channel but the input has %ld channels.", + 1, strip_data.dim3 ()); + } + + // TODO(maged): check dimesnions of boundary strips in matlab strip_data.resize (strip_dimensions); - //TODO(maged): add suppot for 1-bit images - // Permute the dimesions of the strip to match the expected memory // arrangement of LibTIFF (channel x width x height) Array<octave_idx_type> perm (dim_vector (3, 1));