Mercurial > octave-libtiff
changeset 31122:1662939a7a49
Tiff read: moved image_date initialization into a constructor
author | magedrifaat <magedrifaat@gmail.com> |
---|---|
date | Wed, 20 Jul 2022 03:50:43 +0200 |
parents | 341796f9efb6 |
children | 0bcb35909ef4 |
files | libinterp/dldfcn/__tiff__.cc |
diffstat | 1 files changed, 21 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/dldfcn/__tiff__.cc Wed Jul 20 03:44:08 2022 +0200 +++ b/libinterp/dldfcn/__tiff__.cc Wed Jul 20 03:50:43 2022 +0200 @@ -31,6 +31,26 @@ uint16_t bits_per_sample; uint16_t planar_configuration; uint16_t is_tiled; + + tiff_image_data (TIFF *tif) + { + if (! TIFFGetField (tif, TIFFTAG_IMAGEWIDTH, &width)) + error ("Failed to read image width"); + + if (! TIFFGetField (tif, TIFFTAG_IMAGELENGTH, &height)) + error ("Failed to read image height"); + + if (! TIFFGetField (tif, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel)) + error ("Failed to read the SamplesPerPixel tag"); + + if (! TIFFGetField (tif, TIFFTAG_BITSPERSAMPLE, &bits_per_sample)) + error ("Failed to read the BitsPerSample tag"); + + if (! TIFFGetField (tif, TIFFTAG_PLANARCONFIG, &planar_configuration)) + error ("Failed to read the PlanarConfiguration tag"); + + is_tiled = TIFFIsTiled(tif); + } }; // Error if status is not 1 (success status for TIFFGetField) @@ -944,26 +964,7 @@ // will be common among all the different cases of handling the the image // data to avoid repeating the same calls to TIFFGetField in the different // functions as each call is a possible point of failure - tiff_image_data image_data; - if (! TIFFGetField (tif, TIFFTAG_IMAGEWIDTH, &image_data.width)) - error ("Failed to read image width"); - - if (! TIFFGetField (tif, TIFFTAG_IMAGELENGTH, &image_data.height)) - error ("Failed to read image height"); - - if (! TIFFGetField (tif, TIFFTAG_SAMPLESPERPIXEL, - &image_data.samples_per_pixel)) - error ("Failed to read the SamplesPerPixel tag"); - - if (! TIFFGetField (tif, TIFFTAG_BITSPERSAMPLE, - &image_data.bits_per_sample)) - error ("Failed to read the BitsPerSample tag"); - - if (! TIFFGetField (tif, TIFFTAG_PLANARCONFIG, - &image_data.planar_configuration)) - error ("Failed to read the PlanarConfiguration tag"); - - image_data.is_tiled = TIFFIsTiled(tif); + tiff_image_data image_data (tif); octave_value_list retval; switch (image_data.bits_per_sample)