~ubuntu-branches/ubuntu/natty/tiff/natty

« back to all changes in this revision

Viewing changes to tools/tiff2rgba.c

  • Committer: Bazaar Package Importer
  • Author(s): Jay Berkenbilt
  • Date: 2010-06-18 21:28:11 UTC
  • mfrom: (10.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100618212811-3t5mffcr8gpfpuel
Tags: 3.9.4-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: tiff2rgba.c,v 1.13.2.1 2009-08-20 20:23:53 bfriesen Exp $ */
 
1
/* $Id: tiff2rgba.c,v 1.13.2.3 2010-06-12 02:55:16 bfriesen Exp $ */
2
2
 
3
3
/*
4
4
 * Copyright (c) 1991-1997 Sam Leffler
125
125
    return (0);
126
126
}
127
127
 
 
128
#define multiply(a,b) TIFFSafeMultiply(tsize_t,a,b)
 
129
 
128
130
static int
129
131
cvt_by_tile( TIFF *in, TIFF *out )
130
132
 
134
136
    uint32  tile_width, tile_height;
135
137
    uint32  row, col;
136
138
    uint32  *wrk_line;
 
139
    tsize_t raster_size;
137
140
    int     ok = 1;
138
141
 
139
142
    TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width);
151
154
    /*
152
155
     * Allocate tile buffer
153
156
     */
154
 
    raster = (uint32*)_TIFFmalloc(tile_width * tile_height * sizeof (uint32));
 
157
    raster_size = multiply(multiply(tile_width, tile_height), sizeof (uint32));
 
158
    if (!raster_size) {
 
159
        TIFFError(TIFFFileName(in),
 
160
                  "Can't allocate buffer for raster of size %lux%lu",
 
161
                  (unsigned long) tile_width, (unsigned long) tile_height);
 
162
        return (0);
 
163
    }
 
164
    raster = (uint32*)_TIFFmalloc(raster_size);
155
165
    if (raster == 0) {
156
166
        TIFFError(TIFFFileName(in), "No space for raster buffer");
157
167
        return (0);
159
169
 
160
170
    /*
161
171
     * Allocate a scanline buffer for swapping during the vertical
162
 
     * mirroring pass.
 
172
     * mirroring pass.  (Request can't overflow given prior checks.)
163
173
     */
164
174
    wrk_line = (uint32*)_TIFFmalloc(tile_width * sizeof (uint32));
165
175
    if (!wrk_line) {
236
246
    uint32  width, height;              /* image width & height */
237
247
    uint32  row;
238
248
    uint32  *wrk_line;
 
249
    tsize_t raster_size;
239
250
    int     ok = 1;
240
251
 
241
252
    TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width);
251
262
    /*
252
263
     * Allocate strip buffer
253
264
     */
254
 
    raster = (uint32*)_TIFFmalloc(width * rowsperstrip * sizeof (uint32));
 
265
    raster_size = multiply(multiply(width, rowsperstrip), sizeof (uint32));
 
266
    if (!raster_size) {
 
267
        TIFFError(TIFFFileName(in),
 
268
                  "Can't allocate buffer for raster of size %lux%lu",
 
269
                  (unsigned long) width, (unsigned long) rowsperstrip);
 
270
        return (0);
 
271
    }
 
272
    raster = (uint32*)_TIFFmalloc(raster_size);
255
273
    if (raster == 0) {
256
274
        TIFFError(TIFFFileName(in), "No space for raster buffer");
257
275
        return (0);
259
277
 
260
278
    /*
261
279
     * Allocate a scanline buffer for swapping during the vertical
262
 
     * mirroring pass.
 
280
     * mirroring pass.  (Request can't overflow given prior checks.)
263
281
     */
264
282
    wrk_line = (uint32*)_TIFFmalloc(width * sizeof (uint32));
265
283
    if (!wrk_line) {
521
539
}
522
540
 
523
541
/* vim: set ts=8 sts=8 sw=8 noet: */
 
542
/*
 
543
 * Local Variables:
 
544
 * mode: c
 
545
 * c-basic-offset: 8
 
546
 * fill-column: 78
 
547
 * End:
 
548
 */