|
|
878a2b |
#!/bin/bash
|
|
|
878a2b |
#
|
|
|
878a2b |
# svg_convertGplToPpm.sh -- This function takes one palette produced
|
|
|
878a2b |
# by Gimp (e.g., syslinux.gpl) as input and outputs one PPM file based
|
|
|
878a2b |
# on it (e.g., syslinux.ppm).
|
|
|
878a2b |
#
|
|
|
03486a |
# Copyright (C) 2009, 2010, 2011, 2012 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_convertGplToPpm {
|
|
|
878a2b |
|
|
|
878a2b |
local -a FILES
|
|
|
878a2b |
local COUNT=0
|
|
|
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 PPM palette. This is the .ppm file we'll save
|
|
|
878a2b |
# color information to.
|
|
|
878a2b |
local PALETTE_PPM="$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 COLOR=''
|
|
|
878a2b |
local COLORS=$(svg_getColors "$PALETTE_GPL" --head=$NUMBER --tail=$NUMBER --format='rrrggbb')
|
|
|
878a2b |
|
|
|
878a2b |
# Verify amount of colors in the list of colors.
|
|
|
878a2b |
svg_checkColorAmount "$COLORS" "$NUMBER"
|
|
|
878a2b |
|
|
|
878a2b |
# Verify format of colors.
|
|
|
878a2b |
svg_checkColorFormats $COLORS --format='rrggbb'
|
|
|
878a2b |
|
|
|
878a2b |
# Create temporal images (of 1x1 pixel each) to store each color
|
|
|
878a2b |
# retrived from Gimp's palette.
|
|
|
878a2b |
for COLOR in $COLORS;do
|
|
|
878a2b |
FILES[$COUNT]=$(cli_getTemporalFile ${COUNT}.ppm)
|
|
|
878a2b |
ppmmake $COLOR 1 1 > ${FILES[$COUNT]}
|
|
|
878a2b |
COUNT=$(($COUNT + 1))
|
|
|
878a2b |
done
|
|
|
878a2b |
|
|
|
878a2b |
# Concatenate each temporal image from left to right to create the
|
|
|
878a2b |
# PPM file.
|
|
|
878a2b |
pnmcat -lr ${FILES[*]} > $PALETTE_PPM
|
|
|
878a2b |
|
|
|
878a2b |
# Remove temporal images used to build the PPM palette file.
|
|
|
878a2b |
rm ${FILES[*]}
|
|
|
878a2b |
|
|
|
878a2b |
# Verify PPM palette existence.
|
|
|
878a2b |
cli_checkFiles "$PALETTE_PPM"
|
|
|
878a2b |
|
|
|
878a2b |
}
|