| #!/bin/bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| function render_convertGplToPpm { |
| |
| local COLOR='' |
| local COUNT=0 |
| local -a FILES |
| |
| |
| |
| local PALETTE_GPL="$1" |
| |
| |
| |
| local PALETTE_PPM="$2" |
| |
| |
| local COLOR_NUMBER="$3" |
| |
| |
| |
| |
| if [[ ! $COLOR_NUMBER =~ '^(14|16)$' ]];then |
| cli_printMessage "`eval_gettext "Reducing image to \\\`\\\$COLOR_NUMBER' colors is not supported."`" 'AsErrorLine' |
| cli_printMessage "${FUNCDIRNAM}" 'AsToKnowMoreLine' |
| fi |
| |
| # Define list of colors from GPL palette. |
| local COLORS=$(render_getColors "$PALETTE_GPL") |
| |
| # Verify number of colors returned in the list. |
| if [[ ! $(echo "$COLORS" | wc -l) =~ $COLOR_NUMBER ]];then |
| cli_printMessage "`gettext "The palette doesn't have the correct number of colors."`" 'AsErrorLine' |
| cli_printMessage "${FUNCDIRNAM}" 'AsToKnowMoreLine' |
| fi |
| |
| |
| for COLOR in $COLORS;do |
| if [[ ! $COLOR =~ '^[0-9a-f]{6}$' ]];then |
| cli_printMessage "`eval_gettext "The \\\`\\\$COLOR' string isn't a valid color code."`" 'AsErrorLine' |
| cli_printMessage "${FUNCDIRNAM}" 'AsToKnowMoreLine' |
| fi |
| done |
| |
| |
| |
| for COLOR in $COLORS;do |
| FILES[$COUNT]=$(cli_getTemporalFile "color-${COUNT}.ppm") |
| ppmmake $(echo "$COLOR" \ |
| | sed -r 's!(.{2})(.{2})(.{2})!rgb:\1/\2/\3!') 1 1 \ |
| > ${FILES[$COUNT]} |
| COUNT=$(($COUNT + 1)) |
| done |
| |
| |
| |
| pnmcat -lr ${FILES[*]} > $PALETTE_PPM |
| |
| |
| rm ${FILES[*]} |
| |
| |
| cli_checkFiles "$PALETTE_PPM" 'f' |
| |
| } |