|
|
bd5b82 |
#!/bin/bash
|
|
|
bd5b82 |
#
|
|
|
bd5b82 |
# render_convertGplToHex.sh -- This function takes one palette
|
|
|
bd5b82 |
|
|
|
bd5b82 |
|
|
|
bd5b82 |
# `pnmtolss16' program needs (e.g., #RRGGBB=0 #RRGGBB=1 ... [all
|
|
|
bd5b82 |
# values in the same line]).
|
|
|
bd5b82 |
#
|
|
|
fa95b1 |
# Copyright (C) 2009-2011 Alain Reguera Delgado
|
|
|
fa95b1 |
#
|
|
|
fa95b1 |
# This program is free software; you can redistribute it and/or modify
|
|
|
fa95b1 |
|
|
|
fa95b1 |
|
|
|
fa95b1 |
|
|
|
bd5b82 |
#
|
|
|
bd5b82 |
|
|
|
bd5b82 |
|
|
|
bd5b82 |
|
|
|
bd5b82 |
# General Public License for more details.
|
|
|
bd5b82 |
#
|
|
|
bd5b82 |
|
|
|
bd5b82 |
# along with this program; if not, write to the Free Software
|
|
|
bd5b82 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
bd5b82 |
# USA.
|
|
|
bd5b82 |
# ----------------------------------------------------------------------
|
|
|
bd5b82 |
# $Id$
|
|
|
bd5b82 |
# ----------------------------------------------------------------------
|
|
|
bd5b82 |
|
|
|
bd5b82 |
function render_convertGplToHex {
|
|
|
bd5b82 |
|
|
|
bd5b82 |
local COLOR=''
|
|
|
bd5b82 |
local COUNT=0
|
|
|
bd5b82 |
local -a FILES
|
|
|
bd5b82 |
|
|
|
bd5b82 |
|
|
|
bd5b82 |
|
|
|
bd5b82 |
local PALETTE_GPL="$1"
|
|
|
bd5b82 |
|
|
|
bd5b82 |
|
|
|
bd5b82 |
|
|
|
bd5b82 |
local PALETTE_HEX="$2"
|
|
|
bd5b82 |
|
|
|
bd5b82 |
|
|
|
bd5b82 |
local COLOR_NUMBER="$3"
|
|
|
bd5b82 |
|
|
|
bd5b82 |
|
|
|
bd5b82 |
|
|
|
bd5b82 |
|
|
|
bd5b82 |
if [[ ! $COLOR_NUMBER =~ '^(14|16)$' ]];then
|
|
|
bd5b82 |
cli_printMessage "`eval_gettext "Reducing image to \\\`\\\$COLOR_NUMBER' colors is not supported."`" 'AsErrorLine'
|
|
|
eee226 |
cli_printMessage "${FUNCDIRNAM}" 'AsToKnowMoreLine'
|
|
|
bd5b82 |
fi
|
|
|
bd5b82 |
|
|
|
bd5b82 |
|
|
|
bd5b82 |
local COLORS=$(render_getColors "$PALETTE_GPL")
|
|
|
bd5b82 |
|
|
|
bd5b82 |
|
|
|
bd5b82 |
if [[ ! $(echo "$COLORS" | wc -l) =~ $COLOR_NUMBER ]];then
|
|
|
bd5b82 |
cli_printMessage "`gettext "The palette doesn't have the correct number of colors."`" 'AsErrorLine'
|
|
|
eee226 |
cli_printMessage "${FUNCDIRNAM}" 'AsToKnowMoreLine'
|
|
|
bd5b82 |
fi
|
|
|
bd5b82 |
|
|
|
bd5b82 |
|
|
|
bd5b82 |
for COLOR in $COLORS;do
|
|
|
bd5b82 |
if [[ ! $COLOR =~ '^[0-9a-f]{6}$' ]];then
|
|
|
bd5b82 |
cli_printMessage "`eval_gettext "The \\\`\\\$COLOR' string isn't a valid color code."`" 'AsErrorLine'
|
|
|
eee226 |
cli_printMessage "${FUNCDIRNAM}" 'AsToKnowMoreLine'
|
|
|
bd5b82 |
fi
|
|
|
bd5b82 |
done
|
|
|
bd5b82 |
|
|
|
bd5b82 |
|
|
|
bd5b82 |
echo "$COLORS" | nl | awk '{ printf "#%s=%d ", $2, $1 - 1 }' \
|
|
|
bd5b82 |
> $PALETTE_HEX
|
|
|
bd5b82 |
|
|
|
bd5b82 |
|
|
|
bd5b82 |
cli_checkFiles "$PALETTE_PPM" 'f'
|
|
|
bd5b82 |
|
|
|
bd5b82 |
}
|