| 637 | /************************************************************************/ |
| 638 | |
| 639 | void msApplyOutputFormat( outputFormatObj **target, |
| 640 | outputFormatObj *format, |
| 641 | int transparent, |
| 642 | int interlaced, |
| 643 | int imagequality ) |
| 644 | |
| 645 | { |
| 646 | int change_needed = MS_FALSE; |
| 647 | int old_imagequality, old_interlaced; |
| 648 | outputFormatObj *formatToFree = NULL; |
| 649 | |
| 650 | assert( target != NULL ); |
| 651 | |
| 652 | if( *target != NULL && --((*target)->refcount) < 1 ) |
| 653 | { |
| 654 | formatToFree = *target; |
| 655 | *target = NULL; |
| 656 | } |
| 657 | |
| 658 | if( format == NULL ) |
| 659 | { |
| 660 | if( formatToFree ) |
| 661 | msFreeOutputFormat( formatToFree ); |
| 662 | return; |
| 663 | } |
| 664 | |
| 665 | msOutputFormatValidate( format, MS_FALSE ); |
| 666 | |
| 667 | /* -------------------------------------------------------------------- */ |
| 668 | /* Do we need to change any values? If not, then just apply */ |
| 669 | /* and return. */ |
| 670 | /* -------------------------------------------------------------------- */ |
| 671 | if( transparent != MS_NOOVERRIDE && !format->transparent != !transparent ) |
| 672 | change_needed = MS_TRUE; |
| 673 | |
| 674 | old_imagequality = atoi(msGetOutputFormatOption( format, "QUALITY", "75")); |
| 675 | if( imagequality != MS_NOOVERRIDE && old_imagequality != imagequality ) |
| 676 | change_needed = MS_TRUE; |
| 677 | |
| 678 | old_interlaced = |
| 679 | strcasecmp(msGetOutputFormatOption( format, "INTERLACE", "ON"), |
| 680 | "OFF") != 0; |
| 681 | if( interlaced != MS_NOOVERRIDE && !interlaced != !old_interlaced ) |
| 682 | change_needed = MS_TRUE; |
| 683 | |
| 684 | if( change_needed ) |
| 685 | { |
| 686 | char new_value[128]; |
| 687 | |
| 688 | if( format->refcount > 0 ) |
| 689 | format = msCloneOutputFormat( format ); |
| 690 | |
| 691 | if( transparent != MS_NOOVERRIDE ) |
| 692 | { |
| 693 | format->transparent = transparent; |
| 694 | if( format->imagemode == MS_IMAGEMODE_RGB ) |
| 695 | format->imagemode = MS_IMAGEMODE_RGBA; |
| 696 | } |
no test coverage detected