Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 355885
Collapse All | Expand All

(-)file_not_specified_in_diff (-31 / +31 lines)
Line  Link Here
0
-- hugin-2010.4.0/src/foreign/vigra/vigra_impex/png.cxx
0
++ hugin-2010.4.0/src/foreign/vigra/vigra_impex/png.cxx
Lines 78-84 Link Here
78
static void PngError( png_structp png_ptr, png_const_charp error_msg )
78
static void PngError( png_structp png_ptr, png_const_charp error_msg )
79
{
79
{
80
    png_error_message = std::string(error_msg);
80
    png_error_message = std::string(error_msg);
81
    longjmp( png_ptr->jmpbuf, 1 );
81
    longjmp( png_jmpbuf(png_ptr), 1 );
82
}
82
}
83
83
84
// called on non-fatal errors
84
// called on non-fatal errors
Lines 210-216 Link Here
210
        vigra_postcondition( png != 0, "could not create the read struct." );
210
        vigra_postcondition( png != 0, "could not create the read struct." );
211
211
212
        // create info struct
212
        // create info struct
213
        if (setjmp(png->jmpbuf)) {
213
        if (setjmp(png_jmpbuf(png))) {
214
            png_destroy_read_struct( &png, &info, NULL );
214
            png_destroy_read_struct( &png, &info, NULL );
215
            vigra_postcondition( false, png_error_message.insert(0, "error in png_create_info_struct(): ").c_str() );
215
            vigra_postcondition( false, png_error_message.insert(0, "error in png_create_info_struct(): ").c_str() );
216
        }
216
        }
Lines 218-231 Link Here
218
        vigra_postcondition( info != 0, "could not create the info struct." );
218
        vigra_postcondition( info != 0, "could not create the info struct." );
219
219
220
        // init png i/o
220
        // init png i/o
221
        if (setjmp(png->jmpbuf)) {
221
        if (setjmp(png_jmpbuf(png))) {
222
            png_destroy_read_struct( &png, &info, NULL );
222
            png_destroy_read_struct( &png, &info, NULL );
223
            vigra_postcondition( false, png_error_message.insert(0, "error in png_init_io(): ").c_str() );
223
            vigra_postcondition( false, png_error_message.insert(0, "error in png_init_io(): ").c_str() );
224
        }
224
        }
225
        png_init_io( png, file.get() );
225
        png_init_io( png, file.get() );
226
226
227
        // specify that the signature was already read
227
        // specify that the signature was already read
228
        if (setjmp(png->jmpbuf)) {
228
        if (setjmp(png_jmpbuf(png))) {
229
            png_destroy_read_struct( &png, &info, NULL );
229
            png_destroy_read_struct( &png, &info, NULL );
230
            vigra_postcondition( false, png_error_message.insert(0, "error in png_set_sig_bytes(): ").c_str() );
230
            vigra_postcondition( false, png_error_message.insert(0, "error in png_set_sig_bytes(): ").c_str() );
231
        }
231
        }
Lines 241-253 Link Here
241
    void PngDecoderImpl::init()
241
    void PngDecoderImpl::init()
242
    {
242
    {
243
        // read all chunks up to the image data
243
        // read all chunks up to the image data
244
        if (setjmp(png->jmpbuf))
244
        if (setjmp(png_jmpbuf(png)))
245
            vigra_postcondition( false, png_error_message.insert(0, "error in png_read_info(): ").c_str() );
245
            vigra_postcondition( false, png_error_message.insert(0, "error in png_read_info(): ").c_str() );
246
        png_read_info( png, info );
246
        png_read_info( png, info );
247
247
248
        // pull over the header fields
248
        // pull over the header fields
249
        int interlace_method, compression_method, filter_method;
249
        int interlace_method, compression_method, filter_method;
250
        if (setjmp(png->jmpbuf))
250
        if (setjmp(png_jmpbuf(png)))
251
            vigra_postcondition( false, png_error_message.insert(0, "error in png_get_IHDR(): ").c_str() );
251
            vigra_postcondition( false, png_error_message.insert(0, "error in png_get_IHDR(): ").c_str() );
252
        png_get_IHDR( png, info, &width, &height, &bit_depth, &color_type,
252
        png_get_IHDR( png, info, &width, &height, &bit_depth, &color_type,
253
                      &interlace_method, &compression_method, &filter_method );
253
                      &interlace_method, &compression_method, &filter_method );
Lines 261-267 Link Here
261
261
262
        // transform palette to rgb
262
        // transform palette to rgb
263
        if ( color_type == PNG_COLOR_TYPE_PALETTE) {
263
        if ( color_type == PNG_COLOR_TYPE_PALETTE) {
264
            if (setjmp(png->jmpbuf))
264
            if (setjmp(png_jmpbuf(png)))
265
                vigra_postcondition( false, png_error_message.insert(0, "error in png_palette_to_rgb(): ").c_str() );
265
                vigra_postcondition( false, png_error_message.insert(0, "error in png_palette_to_rgb(): ").c_str() );
266
            png_set_palette_to_rgb(png);
266
            png_set_palette_to_rgb(png);
267
            color_type = PNG_COLOR_TYPE_RGB;
267
            color_type = PNG_COLOR_TYPE_RGB;
Lines 271-281 Link Here
271
        // expand gray values to at least one byte size
271
        // expand gray values to at least one byte size
272
        if ( color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8 ) {
272
        if ( color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8 ) {
273
#if (PNG_LIBPNG_VER >= 10400)
273
#if (PNG_LIBPNG_VER >= 10400)
274
            if (setjmp(png->jmpbuf))
274
            if (setjmp(png_jmpbuf(png)))
275
                vigra_postcondition( false,png_error_message.insert(0, "error in png_set_expand_gray_1_2_4_to_8(): ").c_str());
275
                vigra_postcondition( false,png_error_message.insert(0, "error in png_set_expand_gray_1_2_4_to_8(): ").c_str());
276
            png_set_expand_gray_1_2_4_to_8(png);
276
            png_set_expand_gray_1_2_4_to_8(png);
277
#else
277
#else
278
            if (setjmp(png->jmpbuf))
278
            if (setjmp(png_jmpbuf(png)))
279
                vigra_postcondition( false,png_error_message.insert(0, "error in png_set_gray_1_2_4_to_8(): ").c_str());
279
                vigra_postcondition( false,png_error_message.insert(0, "error in png_set_gray_1_2_4_to_8(): ").c_str());
280
            png_set_gray_1_2_4_to_8(png);
280
            png_set_gray_1_2_4_to_8(png);
281
#endif
281
#endif
Lines 286-292 Link Here
286
#if 0
286
#if 0
287
        // strip alpha channel
287
        // strip alpha channel
288
        if ( color_type & PNG_COLOR_MASK_ALPHA ) {
288
        if ( color_type & PNG_COLOR_MASK_ALPHA ) {
289
            if (setjmp(png->jmpbuf))
289
            if (setjmp(png_jmpbuf(png)))
290
                vigra_postcondition( false, png_error_message.insert(0, "error in png_set_strip_alpha(): ").c_str() );
290
                vigra_postcondition( false, png_error_message.insert(0, "error in png_set_strip_alpha(): ").c_str() );
291
            png_set_strip_alpha(png);
291
            png_set_strip_alpha(png);
292
            color_type ^= PNG_COLOR_MASK_ALPHA;
292
            color_type ^= PNG_COLOR_MASK_ALPHA;
Lines 326-337 Link Here
326
326
327
        // read icc profile
327
        // read icc profile
328
#if (PNG_LIBPNG_VER > 10008) && defined(PNG_READ_iCCP_SUPPORTED)
328
#if (PNG_LIBPNG_VER > 10008) && defined(PNG_READ_iCCP_SUPPORTED)
329
        char * dummyName;
329
        png_charpp dummyName;
330
        int dummyCompType;
330
        int dummyCompType;
331
        char * profilePtr;
331
        png_bytepp profilePtr;
332
        png_uint_32 profileLen;
332
        png_uint_32 profileLen;
333
        if (info->valid & PNG_INFO_iCCP) {
333
        if (png_get_valid(png, info, PNG_INFO_iCCP)) {
334
            png_get_iCCP(png, info, &dummyName, &dummyCompType, &profilePtr, &profileLen) ;
334
            png_get_iCCP(png, info, dummyName, &dummyCompType, profilePtr, &profileLen) ;
335
            iccProfilePtr = (unsigned char *) profilePtr;
335
            iccProfilePtr = (unsigned char *) profilePtr;
336
            iccProfileLength = profileLen;
336
            iccProfileLength = profileLen;
337
        }
337
        }
Lines 343-349 Link Here
343
        // image gamma
343
        // image gamma
344
        double image_gamma = 0.45455;
344
        double image_gamma = 0.45455;
345
        if ( png_get_valid( png, info, PNG_INFO_gAMA ) ) {
345
        if ( png_get_valid( png, info, PNG_INFO_gAMA ) ) {
346
            if (setjmp(png->jmpbuf))
346
            if (setjmp(png_jmpbuf(png)))
347
                vigra_postcondition( false, png_error_message.insert(0, "error in png_get_gAMA(): ").c_str() );
347
                vigra_postcondition( false, png_error_message.insert(0, "error in png_get_gAMA(): ").c_str() );
348
            png_get_gAMA( png, info, &image_gamma );
348
            png_get_gAMA( png, info, &image_gamma );
349
        }
349
        }
Lines 352-377 Link Here
352
        double screen_gamma = 2.2;
352
        double screen_gamma = 2.2;
353
353
354
        // set gamma correction
354
        // set gamma correction
355
        if (setjmp(png->jmpbuf))
355
        if (setjmp(png_jmpbuf(png)))
356
            vigra_postcondition( false, png_error_message.insert(0, "error in png_set_gamma(): ").c_str() );
356
            vigra_postcondition( false, png_error_message.insert(0, "error in png_set_gamma(): ").c_str() );
357
        png_set_gamma( png, screen_gamma, image_gamma );
357
        png_set_gamma( png, screen_gamma, image_gamma );
358
#endif
358
#endif
359
359
360
        // interlace handling, get number of read passes needed
360
        // interlace handling, get number of read passes needed
361
        if (setjmp(png->jmpbuf))
361
        if (setjmp(png_jmpbuf(png)))
362
            vigra_postcondition( false,png_error_message.insert(0, "error in png_set_interlace_handling(): ").c_str());
362
            vigra_postcondition( false,png_error_message.insert(0, "error in png_set_interlace_handling(): ").c_str());
363
        n_interlace_passes = png_set_interlace_handling(png);
363
        n_interlace_passes = png_set_interlace_handling(png);
364
364
365
        // update png library state to reflect any changes that were made
365
        // update png library state to reflect any changes that were made
366
        if (setjmp(png->jmpbuf))
366
        if (setjmp(png_jmpbuf(png)))
367
            vigra_postcondition( false, png_error_message.insert(0, "error in png_read_update_info(): ").c_str() );
367
            vigra_postcondition( false, png_error_message.insert(0, "error in png_read_update_info(): ").c_str() );
368
        png_read_update_info( png, info );
368
        png_read_update_info( png, info );
369
369
370
        if (setjmp(png->jmpbuf))
370
        if (setjmp(png_jmpbuf(png)))
371
            vigra_postcondition( false,png_error_message.insert(0, "error in png_get_channels(): ").c_str());
371
            vigra_postcondition( false,png_error_message.insert(0, "error in png_get_channels(): ").c_str());
372
        n_channels = png_get_channels(png, info);
372
        n_channels = png_get_channels(png, info);
373
373
374
        if (setjmp(png->jmpbuf))
374
        if (setjmp(png_jmpbuf(png)))
375
            vigra_postcondition( false,png_error_message.insert(0, "error in png_get_rowbytes(): ").c_str());
375
            vigra_postcondition( false,png_error_message.insert(0, "error in png_get_rowbytes(): ").c_str());
376
        rowsize = png_get_rowbytes(png, info);
376
        rowsize = png_get_rowbytes(png, info);
377
377
Lines 382-388 Link Here
382
    void PngDecoderImpl::nextScanline()
382
    void PngDecoderImpl::nextScanline()
383
    {
383
    {
384
        for (int i=0; i < n_interlace_passes; i++) {
384
        for (int i=0; i < n_interlace_passes; i++) {
385
        if (setjmp(png->jmpbuf))
385
        if (setjmp(png_jmpbuf(png)))
386
                vigra_postcondition( false,png_error_message.insert(0, "error in png_read_row(): ").c_str());
386
                vigra_postcondition( false,png_error_message.insert(0, "error in png_read_row(): ").c_str());
387
            png_read_row(png, row_data.begin(), NULL);
387
            png_read_row(png, row_data.begin(), NULL);
388
        }
388
        }
Lines 548-554 Link Here
548
        vigra_postcondition( png != 0, "could not create the write struct." );
548
        vigra_postcondition( png != 0, "could not create the write struct." );
549
549
550
        // create info struct
550
        // create info struct
551
        if (setjmp(png->jmpbuf)) {
551
        if (setjmp(png_jmpbuf(png))) {
552
            png_destroy_write_struct( &png, &info );
552
            png_destroy_write_struct( &png, &info );
553
            vigra_postcondition( false, png_error_message.insert(0, "error in png_info_struct(): ").c_str() );
553
            vigra_postcondition( false, png_error_message.insert(0, "error in png_info_struct(): ").c_str() );
554
        }
554
        }
Lines 559-565 Link Here
559
        }
559
        }
560
560
561
        // init png i/o
561
        // init png i/o
562
        if (setjmp(png->jmpbuf)) {
562
        if (setjmp(png_jmpbuf(png))) {
563
            png_destroy_write_struct( &png, &info );
563
            png_destroy_write_struct( &png, &info );
564
            vigra_postcondition( false, png_error_message.insert(0, "error in png_init_io(): ").c_str() );
564
            vigra_postcondition( false, png_error_message.insert(0, "error in png_init_io(): ").c_str() );
565
        }
565
        }
Lines 574-580 Link Here
574
    void PngEncoderImpl::finalize()
574
    void PngEncoderImpl::finalize()
575
    {
575
    {
576
        // write the IHDR
576
        // write the IHDR
577
        if (setjmp(png->jmpbuf))
577
        if (setjmp(png_jmpbuf(png)))
578
            vigra_postcondition( false, png_error_message.insert(0, "error in png_set_IHDR(): ").c_str() );
578
            vigra_postcondition( false, png_error_message.insert(0, "error in png_set_IHDR(): ").c_str() );
579
        png_set_IHDR( png, info, width, height, bit_depth, color_type,
579
        png_set_IHDR( png, info, width, height, bit_depth, color_type,
580
                      PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
580
                      PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
Lines 582-588 Link Here
582
582
583
        // set resolution
583
        // set resolution
584
        if (x_resolution > 0 && y_resolution > 0) {
584
        if (x_resolution > 0 && y_resolution > 0) {
585
            if (setjmp(png->jmpbuf))
585
            if (setjmp(png_jmpbuf(png)))
586
                vigra_postcondition( false, png_error_message.insert(0, "error in png_set_pHYs(): ").c_str() );
586
                vigra_postcondition( false, png_error_message.insert(0, "error in png_set_pHYs(): ").c_str() );
587
            png_set_pHYs(png, info, (png_uint_32) (x_resolution * 254 + 0.5),
587
            png_set_pHYs(png, info, (png_uint_32) (x_resolution * 254 + 0.5),
588
                         (png_uint_32) (y_resolution * 254 + 0.5),
588
                         (png_uint_32) (y_resolution * 254 + 0.5),
Lines 591-597 Link Here
591
591
592
        // set offset
592
        // set offset
593
        if (position.x > 0 && position.y > 0) {
593
        if (position.x > 0 && position.y > 0) {
594
            if (setjmp(png->jmpbuf))
594
            if (setjmp(png_jmpbuf(png)))
595
                vigra_postcondition( false, png_error_message.insert(0, "error in png_set_oFFs(): ").c_str() );
595
                vigra_postcondition( false, png_error_message.insert(0, "error in png_set_oFFs(): ").c_str() );
596
            png_set_oFFs(png, info, position.x, position.y, PNG_OFFSET_PIXEL);
596
            png_set_oFFs(png, info, position.x, position.y, PNG_OFFSET_PIXEL);
597
        }
597
        }
Lines 600-611 Link Here
600
        // set icc profile
600
        // set icc profile
601
        if (iccProfile.size() > 0) {
601
        if (iccProfile.size() > 0) {
602
            png_set_iCCP(png, info, "icc", 0,
602
            png_set_iCCP(png, info, "icc", 0,
603
                         (char *)iccProfile.begin(), iccProfile.size());
603
                         iccProfile.begin(), iccProfile.size());
604
        }
604
        }
605
#endif
605
#endif
606
606
607
        // write the info struct
607
        // write the info struct
608
        if (setjmp(png->jmpbuf))
608
        if (setjmp(png_jmpbuf(png)))
609
            vigra_postcondition( false, png_error_message.insert(0, "error in png_write_info(): ").c_str() );
609
            vigra_postcondition( false, png_error_message.insert(0, "error in png_write_info(): ").c_str() );
610
        png_write_info( png, info );
610
        png_write_info( png, info );
611
611
Lines 637-646 Link Here
637
        }
637
        }
638
638
639
        // write the whole image
639
        // write the whole image
640
        if (setjmp(png->jmpbuf))
640
        if (setjmp(png_jmpbuf(png)))
641
            vigra_postcondition( false, png_error_message.insert(0, "error in png_write_image(): ").c_str() );
641
            vigra_postcondition( false, png_error_message.insert(0, "error in png_write_image(): ").c_str() );
642
        png_write_image( png, row_pointers.begin() );
642
        png_write_image( png, row_pointers.begin() );
643
        if (setjmp(png->jmpbuf))
643
        if (setjmp(png_jmpbuf(png)))
644
            vigra_postcondition( false, png_error_message.insert(0, "error in png_write_end(): ").c_str() );
644
            vigra_postcondition( false, png_error_message.insert(0, "error in png_write_end(): ").c_str() );
645
        png_write_end(png, info);
645
        png_write_end(png, info);
646
    }
646
    }

Return to bug 355885