Andrew Geissler | f103a7f | 2021-05-07 16:09:40 -0500 | [diff] [blame] | 1 | From 4ae9904a10f61ed60f4d4ee02eb1994a95664d7b Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Thu, 22 Apr 2021 22:48:59 -0700 |
| 4 | Subject: [PATCH] replace uint32 with uint32_t and uint16 with uint16_6 |
| 5 | |
| 6 | uint16 and uint32 are now deprecated in libtiff and suggestion is to use |
| 7 | standard C99 types |
| 8 | |
| 9 | Upstream-Status: Submitted [https://github.com/libgd/libgd/pull/694] |
| 10 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 11 | --- |
| 12 | src/gd_tiff.c | 52 +++++++++++++++++++++++++-------------------------- |
| 13 | 1 file changed, 26 insertions(+), 26 deletions(-) |
| 14 | |
| 15 | diff --git a/src/gd_tiff.c b/src/gd_tiff.c |
| 16 | index b22ee6c..699d719 100644 |
| 17 | --- a/src/gd_tiff.c |
| 18 | +++ b/src/gd_tiff.c |
| 19 | @@ -237,10 +237,10 @@ void tiffWriter(gdImagePtr image, gdIOCtx *out, int bitDepth) |
| 20 | int transparentColorR = -1; |
| 21 | int transparentColorG = -1; |
| 22 | int transparentColorB = -1; |
| 23 | - uint16 extraSamples[1]; |
| 24 | - uint16 *colorMapRed = NULL; |
| 25 | - uint16 *colorMapGreen = NULL; |
| 26 | - uint16 *colorMapBlue = NULL; |
| 27 | + uint16_t extraSamples[1]; |
| 28 | + uint16_t *colorMapRed = NULL; |
| 29 | + uint16_t *colorMapGreen = NULL; |
| 30 | + uint16_t *colorMapBlue = NULL; |
| 31 | |
| 32 | tiff_handle *th; |
| 33 | |
| 34 | @@ -292,18 +292,18 @@ void tiffWriter(gdImagePtr image, gdIOCtx *out, int bitDepth) |
| 35 | |
| 36 | /* build the color map for 8 bit images */ |
| 37 | if(bitDepth != 24) { |
| 38 | - colorMapRed = (uint16 *) gdMalloc(3 * (1 << bitsPerSample)); |
| 39 | + colorMapRed = (uint16_t *) gdMalloc(3 * (1 << bitsPerSample)); |
| 40 | if (!colorMapRed) { |
| 41 | gdFree(th); |
| 42 | return; |
| 43 | } |
| 44 | - colorMapGreen = (uint16 *) gdMalloc(3 * (1 << bitsPerSample)); |
| 45 | + colorMapGreen = (uint16_t *) gdMalloc(3 * (1 << bitsPerSample)); |
| 46 | if (!colorMapGreen) { |
| 47 | gdFree(colorMapRed); |
| 48 | gdFree(th); |
| 49 | return; |
| 50 | } |
| 51 | - colorMapBlue = (uint16 *) gdMalloc(3 * (1 << bitsPerSample)); |
| 52 | + colorMapBlue = (uint16_t *) gdMalloc(3 * (1 << bitsPerSample)); |
| 53 | if (!colorMapBlue) { |
| 54 | gdFree(colorMapRed); |
| 55 | gdFree(colorMapGreen); |
| 56 | @@ -448,7 +448,7 @@ BGD_DECLARE(void) gdImageTiffCtx(gdImagePtr image, gdIOCtx *out) |
| 57 | /* Check if we are really in 8bit mode */ |
| 58 | static int checkColorMap(n, r, g, b) |
| 59 | int n; |
| 60 | -uint16 *r, *g, *b; |
| 61 | +uint16_t *r, *g, *b; |
| 62 | { |
| 63 | while (n-- > 0) |
| 64 | if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) |
| 65 | @@ -460,8 +460,8 @@ uint16 *r, *g, *b; |
| 66 | /* Read and convert a TIFF colormap */ |
| 67 | static int readTiffColorMap(gdImagePtr im, TIFF *tif, char is_bw, int photometric) |
| 68 | { |
| 69 | - uint16 *redcmap, *greencmap, *bluecmap; |
| 70 | - uint16 bps; |
| 71 | + uint16_t *redcmap, *greencmap, *bluecmap; |
| 72 | + uint16_t bps; |
| 73 | int i; |
| 74 | |
| 75 | if (is_bw) { |
| 76 | @@ -473,7 +473,7 @@ static int readTiffColorMap(gdImagePtr im, TIFF *tif, char is_bw, int photometri |
| 77 | gdImageColorAllocate(im, 255,255,255); |
| 78 | } |
| 79 | } else { |
| 80 | - uint16 min_sample_val, max_sample_val; |
| 81 | + uint16_t min_sample_val, max_sample_val; |
| 82 | |
| 83 | if (!TIFFGetField(tif, TIFFTAG_MINSAMPLEVALUE, &min_sample_val)) { |
| 84 | min_sample_val = 0; |
| 85 | @@ -515,7 +515,7 @@ static int readTiffColorMap(gdImagePtr im, TIFF *tif, char is_bw, int photometri |
| 86 | |
| 87 | static void readTiffBw (const unsigned char *src, |
| 88 | gdImagePtr im, |
| 89 | - uint16 photometric, |
| 90 | + uint16_t photometric, |
| 91 | int startx, |
| 92 | int starty, |
| 93 | int width, |
| 94 | @@ -547,7 +547,7 @@ static void readTiffBw (const unsigned char *src, |
| 95 | |
| 96 | static void readTiff8bit (const unsigned char *src, |
| 97 | gdImagePtr im, |
| 98 | - uint16 photometric, |
| 99 | + uint16_t photometric, |
| 100 | int startx, |
| 101 | int starty, |
| 102 | int width, |
| 103 | @@ -634,10 +634,10 @@ static void readTiff8bit (const unsigned char *src, |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | -static int createFromTiffTiles(TIFF *tif, gdImagePtr im, uint16 bps, uint16 photometric, |
| 108 | +static int createFromTiffTiles(TIFF *tif, gdImagePtr im, uint16_t bps, uint16_t photometric, |
| 109 | char has_alpha, char is_bw, int extra) |
| 110 | { |
| 111 | - uint16 planar; |
| 112 | + uint16_t planar; |
| 113 | int im_width, im_height; |
| 114 | int tile_width, tile_height; |
| 115 | int x, y, height, width; |
| 116 | @@ -682,11 +682,11 @@ end: |
| 117 | return success; |
| 118 | } |
| 119 | |
| 120 | -static int createFromTiffLines(TIFF *tif, gdImagePtr im, uint16 bps, uint16 photometric, |
| 121 | +static int createFromTiffLines(TIFF *tif, gdImagePtr im, uint16_t bps, uint16_t photometric, |
| 122 | char has_alpha, char is_bw, int extra) |
| 123 | { |
| 124 | - uint16 planar; |
| 125 | - uint32 im_height, im_width, y; |
| 126 | + uint16_t planar; |
| 127 | + uint32_t im_height, im_width, y; |
| 128 | |
| 129 | unsigned char *buffer; |
| 130 | int success = GD_SUCCESS; |
| 131 | @@ -761,11 +761,11 @@ static int createFromTiffRgba(TIFF * tif, gdImagePtr im) |
| 132 | int color; |
| 133 | int width = im->sx; |
| 134 | int height = im->sy; |
| 135 | - uint32 *buffer; |
| 136 | - uint32 rgba; |
| 137 | + uint32_t *buffer; |
| 138 | + uint32_t rgba; |
| 139 | int success; |
| 140 | |
| 141 | - buffer = (uint32 *) gdCalloc(sizeof(uint32), width * height); |
| 142 | + buffer = (uint32_t *) gdCalloc(sizeof(uint32_t), width * height); |
| 143 | if (!buffer) { |
| 144 | return GD_FAILURE; |
| 145 | } |
| 146 | @@ -810,11 +810,11 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffCtx(gdIOCtx *infile) |
| 147 | TIFF *tif; |
| 148 | tiff_handle *th; |
| 149 | |
| 150 | - uint16 bps, spp, photometric; |
| 151 | - uint16 orientation; |
| 152 | + uint16_t bps, spp, photometric; |
| 153 | + uint16_t orientation; |
| 154 | int width, height; |
| 155 | - uint16 extra, *extra_types; |
| 156 | - uint16 planar; |
| 157 | + uint16_t extra, *extra_types; |
| 158 | + uint16_t planar; |
| 159 | char has_alpha, is_bw, is_gray; |
| 160 | char force_rgba = FALSE; |
| 161 | char save_transparent; |
| 162 | @@ -867,7 +867,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffCtx(gdIOCtx *infile) |
| 163 | } |
| 164 | |
| 165 | if (!TIFFGetField (tif, TIFFTAG_PHOTOMETRIC, &photometric)) { |
| 166 | - uint16 compression; |
| 167 | + uint16_t compression; |
| 168 | if (TIFFGetField(tif, TIFFTAG_COMPRESSION, &compression) && |
| 169 | (compression == COMPRESSION_CCITTFAX3 || |
| 170 | compression == COMPRESSION_CCITTFAX4 || |