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

« back to all changes in this revision

Viewing changes to libtiff/tif_aux.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: tif_aux.c,v 1.20 2006/06/08 14:24:13 dron Exp $ */
 
1
/* $Id: tif_aux.c,v 1.20.2.3 2010-06-09 21:15:27 bfriesen Exp $ */
2
2
 
3
3
/*
4
4
 * Copyright (c) 1991-1997 Sam Leffler
48
48
 
49
49
        if (cp == NULL)
50
50
                TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
51
 
                             "No space %s", what);
 
51
                             "Failed to allocate memory for %s "
 
52
                             "(%ld elements of %ld bytes each)",
 
53
                             what,(long) nmemb, (long) elem_size);
52
54
 
53
55
        return cp;
54
56
}
100
102
        return 0;
101
103
}
102
104
 
 
105
static int
 
106
TIFFDefaultRefBlackWhite(TIFFDirectory* td)
 
107
{
 
108
        int i;
 
109
 
 
110
        if (!(td->td_refblackwhite = (float *)_TIFFmalloc(6*sizeof (float))))
 
111
                return 0;
 
112
        if (td->td_photometric == PHOTOMETRIC_YCBCR) {
 
113
                /*
 
114
                 * YCbCr (Class Y) images must have the ReferenceBlackWhite
 
115
                 * tag set. Fix the broken images, which lacks that tag.
 
116
                 */
 
117
                td->td_refblackwhite[0] = 0.0F;
 
118
                td->td_refblackwhite[1] = td->td_refblackwhite[3] =
 
119
                        td->td_refblackwhite[5] = 255.0F;
 
120
                td->td_refblackwhite[2] = td->td_refblackwhite[4] = 128.0F;
 
121
        } else {
 
122
                /*
 
123
                 * Assume RGB (Class R)
 
124
                 */
 
125
                for (i = 0; i < 3; i++) {
 
126
                    td->td_refblackwhite[2*i+0] = 0;
 
127
                    td->td_refblackwhite[2*i+1] =
 
128
                            (float)((1L<<td->td_bitspersample)-1L);
 
129
                }
 
130
        }
 
131
        return 1;
 
132
}
 
133
 
103
134
/*
104
135
 * Like TIFFGetField, but return any default
105
136
 * value if the tag is not present in the directory.
225
256
                }
226
257
                return (1);
227
258
        case TIFFTAG_REFERENCEBLACKWHITE:
228
 
                {
229
 
                        int i;
230
 
                        static float ycbcr_refblackwhite[] = 
231
 
                        { 0.0F, 255.0F, 128.0F, 255.0F, 128.0F, 255.0F };
232
 
                        static float rgb_refblackwhite[6];
233
 
 
234
 
                        for (i = 0; i < 3; i++) {
235
 
                                rgb_refblackwhite[2 * i + 0] = 0.0F;
236
 
                                rgb_refblackwhite[2 * i + 1] =
237
 
                                        (float)((1L<<td->td_bitspersample)-1L);
238
 
                        }
239
 
                        
240
 
                        if (td->td_photometric == PHOTOMETRIC_YCBCR) {
241
 
                                /*
242
 
                                 * YCbCr (Class Y) images must have the
243
 
                                 * ReferenceBlackWhite tag set. Fix the
244
 
                                 * broken images, which lacks that tag.
245
 
                                 */
246
 
                                *va_arg(ap, float **) = ycbcr_refblackwhite;
247
 
                        } else {
248
 
                                /*
249
 
                                 * Assume RGB (Class R)
250
 
                                 */
251
 
                                *va_arg(ap, float **) = rgb_refblackwhite;
252
 
                        }
253
 
                        return 1;
254
 
                }
 
259
                if (!td->td_refblackwhite && !TIFFDefaultRefBlackWhite(td))
 
260
                        return (0);
 
261
                *va_arg(ap, float **) = td->td_refblackwhite;
 
262
                return (1);
255
263
        }
256
264
        return 0;
257
265
}
273
281
}
274
282
 
275
283
/* vim: set ts=8 sts=8 sw=8 noet: */
 
284
/*
 
285
 * Local Variables:
 
286
 * mode: c
 
287
 * c-basic-offset: 8
 
288
 * fill-column: 78
 
289
 * End:
 
290
 */