# HG changeset patch # User magedrifaat # Date 1658281843 -7200 # Node ID 1662939a7a49dcc075de05b6afe152695da25631 # Parent 341796f9efb6054f80bcf91748bcc32d4bbe085a Tiff read: moved image_date initialization into a constructor diff -r 341796f9efb6 -r 1662939a7a49 libinterp/dldfcn/__tiff__.cc --- 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)