OLD | NEW |
1 | 1 |
2 /* pngwrite.c - general routines to write a PNG file | 2 /* pngwrite.c - general routines to write a PNG file |
3 * | 3 * |
4 * Last changed in libpng 1.2.45 [July 7, 2011] | 4 * Last changed in libpng 1.2.52 [November 20, 2014] |
5 * Copyright (c) 1998-2011 Glenn Randers-Pehrson | 5 * Copyright (c) 1998-2014 Glenn Randers-Pehrson |
6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) | 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) |
7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) | 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) |
8 * | 8 * |
9 * This code is released under the libpng license. | 9 * This code is released under the libpng license. |
10 * For conditions of distribution and use, see the disclaimer | 10 * For conditions of distribution and use, see the disclaimer |
11 * and license in png.h | 11 * and license in png.h |
12 */ | 12 */ |
13 | 13 |
14 /* Get internal access to png.h */ | 14 /* Get internal access to png.h */ |
15 #define PNG_INTERNAL | 15 #define PNG_INTERNAL |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 #ifdef USE_FAR_KEYWORD | 518 #ifdef USE_FAR_KEYWORD |
519 png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf)); | 519 png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf)); |
520 #endif | 520 #endif |
521 #endif | 521 #endif |
522 | 522 |
523 #ifdef PNG_USER_MEM_SUPPORTED | 523 #ifdef PNG_USER_MEM_SUPPORTED |
524 png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); | 524 png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); |
525 #endif /* PNG_USER_MEM_SUPPORTED */ | 525 #endif /* PNG_USER_MEM_SUPPORTED */ |
526 png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); | 526 png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); |
527 | 527 |
528 if (user_png_ver) | 528 if (user_png_ver != NULL) |
529 { | 529 { |
530 i = 0; | 530 int found_dots = 0; |
| 531 i = -1; |
| 532 |
531 do | 533 do |
532 { | 534 { |
533 if (user_png_ver[i] != png_libpng_ver[i]) | 535 i++; |
| 536 if (user_png_ver[i] != PNG_LIBPNG_VER_STRING[i]) |
534 png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; | 537 png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; |
535 } while (png_libpng_ver[i++]); | 538 if (user_png_ver[i] == '.') |
| 539 found_dots++; |
| 540 } while (found_dots < 2 && user_png_ver[i] != 0 && |
| 541 PNG_LIBPNG_VER_STRING[i] != 0); |
536 } | 542 } |
| 543 else |
| 544 png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; |
537 | 545 |
538 if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) | 546 if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) |
539 { | 547 { |
540 /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so | 548 /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so |
541 * we must recompile any applications that use any older library version. | 549 * we must recompile any applications that use any older library version. |
542 * For versions after libpng 1.0, we will be compatible, so we need | 550 * For versions after libpng 1.0, we will be compatible, so we need |
543 * only check the first digit. | 551 * only check the first digit. |
544 */ | 552 */ |
545 if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || | 553 if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || |
546 (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || | 554 (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 { | 685 { |
678 if (user_png_ver[i] != png_libpng_ver[i]) | 686 if (user_png_ver[i] != png_libpng_ver[i]) |
679 { | 687 { |
680 #ifdef PNG_LEGACY_SUPPORTED | 688 #ifdef PNG_LEGACY_SUPPORTED |
681 png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; | 689 png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; |
682 #else | 690 #else |
683 png_ptr->warning_fn = NULL; | 691 png_ptr->warning_fn = NULL; |
684 png_warning(png_ptr, | 692 png_warning(png_ptr, |
685 "Application uses deprecated png_write_init() and should be recompiled."); | 693 "Application uses deprecated png_write_init() and should be recompiled."); |
686 #endif | 694 #endif |
687 } | 695 } |
688 } while (png_libpng_ver[i++]); | 696 i++; |
| 697 } while (png_libpng_ver[i] != 0 && user_png_ver[i] != 0); |
689 | 698 |
690 png_debug(1, "in png_write_init_3"); | 699 png_debug(1, "in png_write_init_3"); |
691 | 700 |
692 #ifdef PNG_SETJMP_SUPPORTED | 701 #ifdef PNG_SETJMP_SUPPORTED |
693 /* Save jump buffer and error functions */ | 702 /* Save jump buffer and error functions */ |
694 png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf)); | 703 png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf)); |
695 #endif | 704 #endif |
696 | 705 |
697 if (png_sizeof(png_struct) > png_struct_size) | 706 if (png_sizeof(png_struct) > png_struct_size) |
698 { | 707 { |
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1579 | 1588 |
1580 /* ----------------------- end of transformations ------------------- */ | 1589 /* ----------------------- end of transformations ------------------- */ |
1581 | 1590 |
1582 /* Write the bits */ | 1591 /* Write the bits */ |
1583 if (info_ptr->valid & PNG_INFO_IDAT) | 1592 if (info_ptr->valid & PNG_INFO_IDAT) |
1584 png_write_image(png_ptr, info_ptr->row_pointers); | 1593 png_write_image(png_ptr, info_ptr->row_pointers); |
1585 | 1594 |
1586 /* It is REQUIRED to call this to finish writing the rest of the file */ | 1595 /* It is REQUIRED to call this to finish writing the rest of the file */ |
1587 png_write_end(png_ptr, info_ptr); | 1596 png_write_end(png_ptr, info_ptr); |
1588 | 1597 |
1589 transforms = transforms; /* Quiet compiler warnings */ | 1598 PNG_UNUSED(transforms) /* Quiet compiler warnings */ |
1590 params = params; | 1599 PNG_UNUSED(params) |
1591 } | 1600 } |
1592 #endif | 1601 #endif |
1593 #endif /* PNG_WRITE_SUPPORTED */ | 1602 #endif /* PNG_WRITE_SUPPORTED */ |
OLD | NEW |