comparison libinterp/dldfcn/__tiff__.cc @ 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
comparison
equal deleted inserted replaced
31121:341796f9efb6 31122:1662939a7a49
29 uint32_t height; 29 uint32_t height;
30 uint16_t samples_per_pixel; 30 uint16_t samples_per_pixel;
31 uint16_t bits_per_sample; 31 uint16_t bits_per_sample;
32 uint16_t planar_configuration; 32 uint16_t planar_configuration;
33 uint16_t is_tiled; 33 uint16_t is_tiled;
34
35 tiff_image_data (TIFF *tif)
36 {
37 if (! TIFFGetField (tif, TIFFTAG_IMAGEWIDTH, &width))
38 error ("Failed to read image width");
39
40 if (! TIFFGetField (tif, TIFFTAG_IMAGELENGTH, &height))
41 error ("Failed to read image height");
42
43 if (! TIFFGetField (tif, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel))
44 error ("Failed to read the SamplesPerPixel tag");
45
46 if (! TIFFGetField (tif, TIFFTAG_BITSPERSAMPLE, &bits_per_sample))
47 error ("Failed to read the BitsPerSample tag");
48
49 if (! TIFFGetField (tif, TIFFTAG_PLANARCONFIG, &planar_configuration))
50 error ("Failed to read the PlanarConfiguration tag");
51
52 is_tiled = TIFFIsTiled(tif);
53 }
34 }; 54 };
35 55
36 // Error if status is not 1 (success status for TIFFGetField) 56 // Error if status is not 1 (success status for TIFFGetField)
37 void 57 void
38 validate_tiff_get_field (bool status, void *p_to_free=NULL) 58 validate_tiff_get_field (bool status, void *p_to_free=NULL)
942 // Obtain all necessary tags 962 // Obtain all necessary tags
943 // The main purpose of this struct is to hold all the necessary tags that 963 // The main purpose of this struct is to hold all the necessary tags that
944 // will be common among all the different cases of handling the the image 964 // will be common among all the different cases of handling the the image
945 // data to avoid repeating the same calls to TIFFGetField in the different 965 // data to avoid repeating the same calls to TIFFGetField in the different
946 // functions as each call is a possible point of failure 966 // functions as each call is a possible point of failure
947 tiff_image_data image_data; 967 tiff_image_data image_data (tif);
948 if (! TIFFGetField (tif, TIFFTAG_IMAGEWIDTH, &image_data.width))
949 error ("Failed to read image width");
950
951 if (! TIFFGetField (tif, TIFFTAG_IMAGELENGTH, &image_data.height))
952 error ("Failed to read image height");
953
954 if (! TIFFGetField (tif, TIFFTAG_SAMPLESPERPIXEL,
955 &image_data.samples_per_pixel))
956 error ("Failed to read the SamplesPerPixel tag");
957
958 if (! TIFFGetField (tif, TIFFTAG_BITSPERSAMPLE,
959 &image_data.bits_per_sample))
960 error ("Failed to read the BitsPerSample tag");
961
962 if (! TIFFGetField (tif, TIFFTAG_PLANARCONFIG,
963 &image_data.planar_configuration))
964 error ("Failed to read the PlanarConfiguration tag");
965
966 image_data.is_tiled = TIFFIsTiled(tif);
967 968
968 octave_value_list retval; 969 octave_value_list retval;
969 switch (image_data.bits_per_sample) 970 switch (image_data.bits_per_sample)
970 { 971 {
971 case 1: 972 case 1: