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