OLD | NEW |
1 /* $Id: tif_tile.c,v 1.23 2012-06-06 05:33:55 fwarmerdam Exp $ */ | 1 /* $Id: tif_tile.c,v 1.24 2015-06-07 22:35:40 bfriesen Exp $ */ |
2 | 2 |
3 /* | 3 /* |
4 * Copyright (c) 1991-1997 Sam Leffler | 4 * Copyright (c) 1991-1997 Sam Leffler |
5 * Copyright (c) 1991-1997 Silicon Graphics, Inc. | 5 * Copyright (c) 1991-1997 Silicon Graphics, Inc. |
6 * | 6 * |
7 * Permission to use, copy, modify, distribute, and sell this software and | 7 * Permission to use, copy, modify, distribute, and sell this software and |
8 * its documentation for any purpose is hereby granted without fee, provided | 8 * its documentation for any purpose is hereby granted without fee, provided |
9 * that (i) the above copyright notices and this permission notice appear in | 9 * that (i) the above copyright notices and this permission notice appear in |
10 * all copies of the software and related documentation, and (ii) the names of | 10 * all copies of the software and related documentation, and (ii) the names of |
11 * Sam Leffler and Silicon Graphics may not be used in any advertising or | 11 * Sam Leffler and Silicon Graphics may not be used in any advertising or |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 "TIFFNumberOfTiles"); | 136 "TIFFNumberOfTiles"); |
137 return (ntiles); | 137 return (ntiles); |
138 } | 138 } |
139 | 139 |
140 /* | 140 /* |
141 * Compute the # bytes in each row of a tile. | 141 * Compute the # bytes in each row of a tile. |
142 */ | 142 */ |
143 uint64 | 143 uint64 |
144 TIFFTileRowSize64(TIFF* tif) | 144 TIFFTileRowSize64(TIFF* tif) |
145 { | 145 { |
| 146 static const char module[] = "TIFFTileRowSize64"; |
146 TIFFDirectory *td = &tif->tif_dir; | 147 TIFFDirectory *td = &tif->tif_dir; |
147 uint64 rowsize; | 148 uint64 rowsize; |
| 149 uint64 tilerowsize; |
148 | 150 |
149 » if (td->td_tilelength == 0 || td->td_tilewidth == 0) | 151 » if (td->td_tilelength == 0) |
| 152 { |
| 153 TIFFErrorExt(tif->tif_clientdata,module,"Tile length is zero"); |
| 154 return 0; |
| 155 } |
| 156 if (td->td_tilewidth == 0) |
| 157 { |
| 158 TIFFErrorExt(tif->tif_clientdata,module,"Tile width is zero"); |
150 return (0); | 159 return (0); |
| 160 } |
151 rowsize = _TIFFMultiply64(tif, td->td_bitspersample, td->td_tilewidth, | 161 rowsize = _TIFFMultiply64(tif, td->td_bitspersample, td->td_tilewidth, |
152 "TIFFTileRowSize"); | 162 "TIFFTileRowSize"); |
153 if (td->td_planarconfig == PLANARCONFIG_CONTIG) | 163 if (td->td_planarconfig == PLANARCONFIG_CONTIG) |
| 164 { |
| 165 if (td->td_samplesperpixel == 0) |
| 166 { |
| 167 TIFFErrorExt(tif->tif_clientdata,module,"Samples per pix
el is zero"); |
| 168 return 0; |
| 169 } |
154 rowsize = _TIFFMultiply64(tif, rowsize, td->td_samplesperpixel, | 170 rowsize = _TIFFMultiply64(tif, rowsize, td->td_samplesperpixel, |
155 "TIFFTileRowSize"); | 171 "TIFFTileRowSize"); |
156 » return (TIFFhowmany8_64(rowsize)); | 172 } |
| 173 tilerowsize=TIFFhowmany8_64(rowsize); |
| 174 if (tilerowsize == 0) |
| 175 { |
| 176 TIFFErrorExt(tif->tif_clientdata,module,"Computed tile row size
is zero"); |
| 177 return 0; |
| 178 } |
| 179 » return (tilerowsize); |
157 } | 180 } |
158 tmsize_t | 181 tmsize_t |
159 TIFFTileRowSize(TIFF* tif) | 182 TIFFTileRowSize(TIFF* tif) |
160 { | 183 { |
161 static const char module[] = "TIFFTileRowSize"; | 184 static const char module[] = "TIFFTileRowSize"; |
162 uint64 m; | 185 uint64 m; |
163 tmsize_t n; | 186 tmsize_t n; |
164 m=TIFFTileRowSize64(tif); | 187 m=TIFFTileRowSize64(tif); |
165 n=(tmsize_t)m; | 188 n=(tmsize_t)m; |
166 if ((uint64)n!=m) | 189 if ((uint64)n!=m) |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 } | 313 } |
291 | 314 |
292 /* vim: set ts=8 sts=8 sw=8 noet: */ | 315 /* vim: set ts=8 sts=8 sw=8 noet: */ |
293 /* | 316 /* |
294 * Local Variables: | 317 * Local Variables: |
295 * mode: c | 318 * mode: c |
296 * c-basic-offset: 8 | 319 * c-basic-offset: 8 |
297 * fill-column: 78 | 320 * fill-column: 78 |
298 * End: | 321 * End: |
299 */ | 322 */ |
300 | |
OLD | NEW |