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

(-)file_not_specified_in_diff (-30 / +30 lines)
Line  Link Here
0
-- src/vigra_impex/png.cxx
0
++ src/vigra_impex/png.cxx
Lines 81-87 Link Here
81
static void PngError( png_structp png_ptr, png_const_charp error_msg )
81
static void PngError( png_structp png_ptr, png_const_charp error_msg )
82
{
82
{
83
    png_error_message = std::string(error_msg);
83
    png_error_message = std::string(error_msg);
84
    longjmp( png_ptr->jmpbuf, 1 );
84
    longjmp( png_jmpbuf( png_ptr ), 1 );
85
}
85
}
86
86
87
// called on non-fatal errors
87
// called on non-fatal errors
Lines 213-219 Link Here
213
        vigra_postcondition( png != 0, "could not create the read struct." );
213
        vigra_postcondition( png != 0, "could not create the read struct." );
214
214
215
        // create info struct
215
        // create info struct
216
        if (setjmp(png->jmpbuf)) {
216
        if (setjmp(png_jmpbuf( png ))) {
217
            png_destroy_read_struct( &png, &info, NULL );
217
            png_destroy_read_struct( &png, &info, NULL );
218
            vigra_postcondition( false, png_error_message.insert(0, "error in png_create_info_struct(): ").c_str() );
218
            vigra_postcondition( false, png_error_message.insert(0, "error in png_create_info_struct(): ").c_str() );
219
        }
219
        }
Lines 221-234 Link Here
221
        vigra_postcondition( info != 0, "could not create the info struct." );
221
        vigra_postcondition( info != 0, "could not create the info struct." );
222
222
223
        // init png i/o
223
        // init png i/o
224
        if (setjmp(png->jmpbuf)) {
224
        if (setjmp(png_jmpbuf( png ))) {
225
            png_destroy_read_struct( &png, &info, NULL );
225
            png_destroy_read_struct( &png, &info, NULL );
226
            vigra_postcondition( false, png_error_message.insert(0, "error in png_init_io(): ").c_str() );
226
            vigra_postcondition( false, png_error_message.insert(0, "error in png_init_io(): ").c_str() );
227
        }
227
        }
228
        png_init_io( png, file.get() );
228
        png_init_io( png, file.get() );
229
229
230
        // specify that the signature was already read
230
        // specify that the signature was already read
231
        if (setjmp(png->jmpbuf)) {
231
        if (setjmp(png_jmpbuf( png ))) {
232
            png_destroy_read_struct( &png, &info, NULL );
232
            png_destroy_read_struct( &png, &info, NULL );
233
            vigra_postcondition( false, png_error_message.insert(0, "error in png_set_sig_bytes(): ").c_str() );
233
            vigra_postcondition( false, png_error_message.insert(0, "error in png_set_sig_bytes(): ").c_str() );
234
        }
234
        }
Lines 244-256 Link Here
244
    void PngDecoderImpl::init()
244
    void PngDecoderImpl::init()
245
    {
245
    {
246
        // read all chunks up to the image data
246
        // read all chunks up to the image data
247
        if (setjmp(png->jmpbuf))
247
        if (setjmp(png_jmpbuf( png )))
248
            vigra_postcondition( false, png_error_message.insert(0, "error in png_read_info(): ").c_str() );
248
            vigra_postcondition( false, png_error_message.insert(0, "error in png_read_info(): ").c_str() );
249
        png_read_info( png, info );
249
        png_read_info( png, info );
250
250
251
        // pull over the header fields
251
        // pull over the header fields
252
        int interlace_method, compression_method, filter_method;
252
        int interlace_method, compression_method, filter_method;
253
        if (setjmp(png->jmpbuf))
253
        if (setjmp(png_jmpbuf( png )))
254
            vigra_postcondition( false, png_error_message.insert(0, "error in png_get_IHDR(): ").c_str() );
254
            vigra_postcondition( false, png_error_message.insert(0, "error in png_get_IHDR(): ").c_str() );
255
        png_get_IHDR( png, info, &width, &height, &bit_depth, &color_type,
255
        png_get_IHDR( png, info, &width, &height, &bit_depth, &color_type,
256
                      &interlace_method, &compression_method, &filter_method );
256
                      &interlace_method, &compression_method, &filter_method );
Lines 264-270 Link Here
264
264
265
        // transform palette to rgb
265
        // transform palette to rgb
266
        if ( color_type == PNG_COLOR_TYPE_PALETTE) {
266
        if ( color_type == PNG_COLOR_TYPE_PALETTE) {
267
            if (setjmp(png->jmpbuf))
267
            if (setjmp(png_jmpbuf( png )))
268
                vigra_postcondition( false, png_error_message.insert(0, "error in png_palette_to_rgb(): ").c_str() );
268
                vigra_postcondition( false, png_error_message.insert(0, "error in png_palette_to_rgb(): ").c_str() );
269
            png_set_palette_to_rgb(png);
269
            png_set_palette_to_rgb(png);
270
            color_type = PNG_COLOR_TYPE_RGB;
270
            color_type = PNG_COLOR_TYPE_RGB;
Lines 273-279 Link Here
273
273
274
        // expand gray values to at least one byte size
274
        // expand gray values to at least one byte size
275
        if ( color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8 ) {
275
        if ( color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8 ) {
276
            if (setjmp(png->jmpbuf))
276
            if (setjmp(png_jmpbuf( png )))
277
                vigra_postcondition( false,png_error_message.insert(0, "error in png_set_expand_gray_1_2_4_to_8(): ").c_str());
277
                vigra_postcondition( false,png_error_message.insert(0, "error in png_set_expand_gray_1_2_4_to_8(): ").c_str());
278
            png_set_expand_gray_1_2_4_to_8(png);
278
            png_set_expand_gray_1_2_4_to_8(png);
279
            bit_depth = 8;
279
            bit_depth = 8;
Lines 283-289 Link Here
283
#if 0
283
#if 0
284
        // strip alpha channel
284
        // strip alpha channel
285
        if ( color_type & PNG_COLOR_MASK_ALPHA ) {
285
        if ( color_type & PNG_COLOR_MASK_ALPHA ) {
286
            if (setjmp(png->jmpbuf))
286
            if (setjmp(png_jmpbuf( png )))
287
                vigra_postcondition( false, png_error_message.insert(0, "error in png_set_strip_alpha(): ").c_str() );
287
                vigra_postcondition( false, png_error_message.insert(0, "error in png_set_strip_alpha(): ").c_str() );
288
            png_set_strip_alpha(png);
288
            png_set_strip_alpha(png);
289
            color_type ^= PNG_COLOR_MASK_ALPHA;
289
            color_type ^= PNG_COLOR_MASK_ALPHA;
Lines 323-334 Link Here
323
323
324
        // read icc profile
324
        // read icc profile
325
#if (PNG_LIBPNG_VER > 10008) && defined(PNG_READ_iCCP_SUPPORTED)
325
#if (PNG_LIBPNG_VER > 10008) && defined(PNG_READ_iCCP_SUPPORTED)
326
        char * dummyName;
326
        png_charpp dummyName;
327
        int dummyCompType;
327
        int dummyCompType;
328
        char * profilePtr;
328
        png_bytepp profilePtr;
329
        png_uint_32 profileLen;
329
        png_uint_32 profileLen;
330
        if (info->valid & PNG_INFO_iCCP) {
330
        if (png_get_valid(png, info, PNG_INFO_iCCP)) {
331
            png_get_iCCP(png, info, &dummyName, &dummyCompType, &profilePtr, &profileLen) ;
331
            png_get_iCCP(png, info, dummyName, &dummyCompType, profilePtr, &profileLen) ;
332
            iccProfilePtr = (unsigned char *) profilePtr;
332
            iccProfilePtr = (unsigned char *) profilePtr;
333
            iccProfileLength = profileLen;
333
            iccProfileLength = profileLen;
334
        }
334
        }
Lines 340-346 Link Here
340
        // image gamma
340
        // image gamma
341
        double image_gamma = 0.45455;
341
        double image_gamma = 0.45455;
342
        if ( png_get_valid( png, info, PNG_INFO_gAMA ) ) {
342
        if ( png_get_valid( png, info, PNG_INFO_gAMA ) ) {
343
            if (setjmp(png->jmpbuf))
343
            if (setjmp(png_jmpbuf( png )))
344
                vigra_postcondition( false, png_error_message.insert(0, "error in png_get_gAMA(): ").c_str() );
344
                vigra_postcondition( false, png_error_message.insert(0, "error in png_get_gAMA(): ").c_str() );
345
            png_get_gAMA( png, info, &image_gamma );
345
            png_get_gAMA( png, info, &image_gamma );
346
        }
346
        }
Lines 349-374 Link Here
349
        double screen_gamma = 2.2;
349
        double screen_gamma = 2.2;
350
350
351
        // set gamma correction
351
        // set gamma correction
352
        if (setjmp(png->jmpbuf))
352
        if (setjmp(png_jmpbuf( png )))
353
            vigra_postcondition( false, png_error_message.insert(0, "error in png_set_gamma(): ").c_str() );
353
            vigra_postcondition( false, png_error_message.insert(0, "error in png_set_gamma(): ").c_str() );
354
        png_set_gamma( png, screen_gamma, image_gamma );
354
        png_set_gamma( png, screen_gamma, image_gamma );
355
#endif
355
#endif
356
356
357
        // interlace handling, get number of read passes needed
357
        // interlace handling, get number of read passes needed
358
        if (setjmp(png->jmpbuf))
358
        if (setjmp(png_jmpbuf( png )))
359
            vigra_postcondition( false,png_error_message.insert(0, "error in png_set_interlace_handling(): ").c_str());
359
            vigra_postcondition( false,png_error_message.insert(0, "error in png_set_interlace_handling(): ").c_str());
360
        n_interlace_passes = png_set_interlace_handling(png);
360
        n_interlace_passes = png_set_interlace_handling(png);
361
361
362
        // update png library state to reflect any changes that were made
362
        // update png library state to reflect any changes that were made
363
        if (setjmp(png->jmpbuf))
363
        if (setjmp(png_jmpbuf( png )))
364
            vigra_postcondition( false, png_error_message.insert(0, "error in png_read_update_info(): ").c_str() );
364
            vigra_postcondition( false, png_error_message.insert(0, "error in png_read_update_info(): ").c_str() );
365
        png_read_update_info( png, info );
365
        png_read_update_info( png, info );
366
366
367
        if (setjmp(png->jmpbuf))
367
        if (setjmp(png_jmpbuf( png )))
368
            vigra_postcondition( false,png_error_message.insert(0, "error in png_get_channels(): ").c_str());
368
            vigra_postcondition( false,png_error_message.insert(0, "error in png_get_channels(): ").c_str());
369
        n_channels = png_get_channels(png, info);
369
        n_channels = png_get_channels(png, info);
370
370
371
        if (setjmp(png->jmpbuf))
371
        if (setjmp(png_jmpbuf( png )))
372
            vigra_postcondition( false,png_error_message.insert(0, "error in png_get_rowbytes(): ").c_str());
372
            vigra_postcondition( false,png_error_message.insert(0, "error in png_get_rowbytes(): ").c_str());
373
        rowsize = png_get_rowbytes(png, info);
373
        rowsize = png_get_rowbytes(png, info);
374
374
Lines 379-385 Link Here
379
    void PngDecoderImpl::nextScanline()
379
    void PngDecoderImpl::nextScanline()
380
    {
380
    {
381
        for (int i=0; i < n_interlace_passes; i++) {
381
        for (int i=0; i < n_interlace_passes; i++) {
382
        if (setjmp(png->jmpbuf))
382
        if (setjmp(png_jmpbuf( png )))
383
                vigra_postcondition( false,png_error_message.insert(0, "error in png_read_row(): ").c_str());
383
                vigra_postcondition( false,png_error_message.insert(0, "error in png_read_row(): ").c_str());
384
            png_read_row(png, row_data.begin(), NULL);
384
            png_read_row(png, row_data.begin(), NULL);
385
        }
385
        }
Lines 545-551 Link Here
545
        vigra_postcondition( png != 0, "could not create the write struct." );
545
        vigra_postcondition( png != 0, "could not create the write struct." );
546
546
547
        // create info struct
547
        // create info struct
548
        if (setjmp(png->jmpbuf)) {
548
        if (setjmp(png_jmpbuf( png ))) {
549
            png_destroy_write_struct( &png, &info );
549
            png_destroy_write_struct( &png, &info );
550
            vigra_postcondition( false, png_error_message.insert(0, "error in png_info_struct(): ").c_str() );
550
            vigra_postcondition( false, png_error_message.insert(0, "error in png_info_struct(): ").c_str() );
551
        }
551
        }
Lines 556-562 Link Here
556
        }
556
        }
557
557
558
        // init png i/o
558
        // init png i/o
559
        if (setjmp(png->jmpbuf)) {
559
        if (setjmp(png_jmpbuf( png ))) {
560
            png_destroy_write_struct( &png, &info );
560
            png_destroy_write_struct( &png, &info );
561
            vigra_postcondition( false, png_error_message.insert(0, "error in png_init_io(): ").c_str() );
561
            vigra_postcondition( false, png_error_message.insert(0, "error in png_init_io(): ").c_str() );
562
        }
562
        }
Lines 571-577 Link Here
571
    void PngEncoderImpl::finalize()
571
    void PngEncoderImpl::finalize()
572
    {
572
    {
573
        // write the IHDR
573
        // write the IHDR
574
        if (setjmp(png->jmpbuf))
574
        if (setjmp(png_jmpbuf( png )))
575
            vigra_postcondition( false, png_error_message.insert(0, "error in png_set_IHDR(): ").c_str() );
575
            vigra_postcondition( false, png_error_message.insert(0, "error in png_set_IHDR(): ").c_str() );
576
        png_set_IHDR( png, info, width, height, bit_depth, color_type,
576
        png_set_IHDR( png, info, width, height, bit_depth, color_type,
577
                      PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
577
                      PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
Lines 579-585 Link Here
579
579
580
        // set resolution
580
        // set resolution
581
        if (x_resolution > 0 && y_resolution > 0) {
581
        if (x_resolution > 0 && y_resolution > 0) {
582
            if (setjmp(png->jmpbuf))
582
            if (setjmp(png_jmpbuf( png )))
583
                vigra_postcondition( false, png_error_message.insert(0, "error in png_set_pHYs(): ").c_str() );
583
                vigra_postcondition( false, png_error_message.insert(0, "error in png_set_pHYs(): ").c_str() );
584
            png_set_pHYs(png, info, (png_uint_32) (x_resolution / 0.0254 + 0.5),
584
            png_set_pHYs(png, info, (png_uint_32) (x_resolution / 0.0254 + 0.5),
585
                         (png_uint_32) (y_resolution / 0.0254 + 0.5),
585
                         (png_uint_32) (y_resolution / 0.0254 + 0.5),
Lines 588-594 Link Here
588
588
589
        // set offset
589
        // set offset
590
        if (position.x > 0 && position.y > 0) {
590
        if (position.x > 0 && position.y > 0) {
591
            if (setjmp(png->jmpbuf))
591
            if (setjmp(png_jmpbuf( png )))
592
                vigra_postcondition( false, png_error_message.insert(0, "error in png_set_oFFs(): ").c_str() );
592
                vigra_postcondition( false, png_error_message.insert(0, "error in png_set_oFFs(): ").c_str() );
593
            png_set_oFFs(png, info, position.x, position.y, PNG_OFFSET_PIXEL);
593
            png_set_oFFs(png, info, position.x, position.y, PNG_OFFSET_PIXEL);
594
        }
594
        }
Lines 597-608 Link Here
597
        // set icc profile
597
        // set icc profile
598
        if (iccProfile.size() > 0) {
598
        if (iccProfile.size() > 0) {
599
            png_set_iCCP(png, info, "icc", 0,
599
            png_set_iCCP(png, info, "icc", 0,
600
                         (char *)iccProfile.begin(), iccProfile.size());
600
                         iccProfile.begin(), iccProfile.size());
601
        }
601
        }
602
#endif
602
#endif
603
603
604
        // write the info struct
604
        // write the info struct
605
        if (setjmp(png->jmpbuf))
605
        if (setjmp(png_jmpbuf( png )))
606
            vigra_postcondition( false, png_error_message.insert(0, "error in png_write_info(): ").c_str() );
606
            vigra_postcondition( false, png_error_message.insert(0, "error in png_write_info(): ").c_str() );
607
        png_write_info( png, info );
607
        png_write_info( png, info );
608
608
Lines 634-643 Link Here
634
        }
634
        }
635
635
636
        // write the whole image
636
        // write the whole image
637
        if (setjmp(png->jmpbuf))
637
        if (setjmp(png_jmpbuf( png )))
638
            vigra_postcondition( false, png_error_message.insert(0, "error in png_write_image(): ").c_str() );
638
            vigra_postcondition( false, png_error_message.insert(0, "error in png_write_image(): ").c_str() );
639
        png_write_image( png, row_pointers.begin() );
639
        png_write_image( png, row_pointers.begin() );
640
        if (setjmp(png->jmpbuf))
640
        if (setjmp(png_jmpbuf( png )))
641
            vigra_postcondition( false, png_error_message.insert(0, "error in png_write_end(): ").c_str() );
641
            vigra_postcondition( false, png_error_message.insert(0, "error in png_write_end(): ").c_str() );
642
        png_write_end(png, info);
642
        png_write_end(png, info);
643
    }
643
    }

Return to bug 355893