|
|
878a2b |
#!/bin/bash
|
|
|
878a2b |
#
|
|
|
878a2b |
# svg_convertGplToHex.sh -- This function takes one palette produced
|
|
|
878a2b |
# by Gimp (e.g., syslinux.gpl) as input and outputs the list of
|
|
|
878a2b |
# hexadecimal colors and their respective index position the
|
|
|
878a2b |
# `pnmtolss16' program needs (e.g., #RRGGBB=0 #RRGGBB=1 ... [all
|
|
|
878a2b |
# values in the same line]).
|
|
|
878a2b |
#
|
|
|
878a2b |
# Copyright (C) 2009, 2010, 2011 The CentOS Project
|
|
|
878a2b |
#
|
|
|
878a2b |
# This program is free software; you can redistribute it and/or modify
|
|
|
878a2b |
# it under the terms of the GNU General Public License as published by
|
|
|
878a2b |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
878a2b |
# your option) any later version.
|
|
|
878a2b |
#
|
|
|
878a2b |
# This program is distributed in the hope that it will be useful, but
|
|
|
878a2b |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
878a2b |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
878a2b |
# General Public License for more details.
|
|
|
878a2b |
#
|
|
|
878a2b |
# You should have received a copy of the GNU General Public License
|
|
|
878a2b |
# along with this program; if not, write to the Free Software
|
|
|
878a2b |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
878a2b |
#
|
|
|
878a2b |
# ----------------------------------------------------------------------
|
|
|
878a2b |
# $Id$
|
|
|
878a2b |
# ----------------------------------------------------------------------
|
|
|
878a2b |
|
|
|
878a2b |
function svg_convertGplToHex {
|
|
|
878a2b |
|
|
|
878a2b |
# Define path to GPL palette. This is the .gpl file we use to
|
|
|
878a2b |
# retrive color information from.
|
|
|
878a2b |
local PALETTE_GPL="$1"
|
|
|
878a2b |
|
|
|
878a2b |
# Define path to HEX palette. This is the palette used to stored
|
|
|
878a2b |
# the color information the `ppmtolss16' program needs.
|
|
|
878a2b |
local PALETTE_HEX="$2"
|
|
|
878a2b |
|
|
|
878a2b |
# Define the number of colors this function should return.
|
|
|
878a2b |
local NUMBER="$3"
|
|
|
878a2b |
|
|
|
878a2b |
# Define list of colors from GPL palette.
|
|
|
878a2b |
local COLORS=$(svg_getColors $PALETTE_GPL --head=$NUMBER --tail=$NUMBER)
|
|
|
878a2b |
|
|
|
878a2b |
# Verify number of colors returned in the list. They must match
|
|
|
878a2b |
# exactly the amount specified, no more no less. Sometimes, the
|
|
|
878a2b |
# list of colors may have less colors than it should have, so we
|
|
|
878a2b |
# need to prevent such palettes from being used.
|
|
|
878a2b |
svg_checkColorAmount "$COLORS" "$NUMBER"
|
|
|
878a2b |
|
|
|
878a2b |
# Verify format of colors.
|
|
|
878a2b |
svg_checkColorFormats "$COLORS" --format='rrggbb'
|
|
|
878a2b |
|
|
|
878a2b |
# Create list of colors to be processed by `pnmtolss16'.
|
|
|
878a2b |
echo "$COLORS" | nl | gawk '{ printf "%s=%d ", $2, $1 - 1 }' \
|
|
|
878a2b |
> $PALETTE_HEX
|
|
|
878a2b |
|
|
|
878a2b |
# Verify HEX palette existence.
|
|
|
878a2b |
cli_checkFiles $PALETTE_HEX
|
|
|
878a2b |
|
|
|
878a2b |
}
|