|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# render_doIdentityImageSyslinux.sh -- This function provides
|
|
|
15b1d2 |
# post-rendition action used to produce syslinux images.
|
|
|
4c79b5 |
#
|
|
|
9f5f2e |
# Copyright (C) 2009-2011 Alain Reguera Delgado
|
|
|
4c79b5 |
#
|
|
|
7cd8e9 |
# This program is free software; you can redistribute it and/or
|
|
|
7cd8e9 |
# modify it under the terms of the GNU General Public License as
|
|
|
7cd8e9 |
# published by the Free Software Foundation; either version 2 of the
|
|
|
7cd8e9 |
# License, or (at your option) any later version.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# This program is distributed in the hope that it will be useful, but
|
|
|
4c79b5 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
4c79b5 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
4c79b5 |
# General Public License for more details.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# You should have received a copy of the GNU General Public License
|
|
|
4c79b5 |
# along with this program; if not, write to the Free Software
|
|
|
4c79b5 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
4c79b5 |
# USA.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
418249 |
# $Id$
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
4c79b5 |
|
|
|
4c79b5 |
function render_doIdentityImageSyslinux {
|
|
|
4c79b5 |
|
|
|
4c79b5 |
local FILE=$1
|
|
|
f16762 |
local ACTION="$2"
|
|
|
f16762 |
local OPTIONS=''
|
|
|
f16762 |
|
|
|
f16762 |
# Define 16 colors images default file name prefix.
|
|
|
f16762 |
local PREFIX='-16c'
|
|
|
f16762 |
|
|
|
15b1d2 |
# Define options using those passed to actions from pre-rendition
|
|
|
f16762 |
# configuration script. These options are applied to pnmremap when
|
|
|
f16762 |
# doing color reduction, so any option available for pnmremap
|
|
|
f16762 |
# command can be passed to renderSyslinux functionality.
|
|
|
eb0e14 |
OPTIONS=$(render_getConfOption "$ACTION" '2-')
|
|
|
f16762 |
|
|
|
f16762 |
# Check options passed to action. This is required in order to
|
|
|
f16762 |
# aviod using options used already in this script. For example
|
|
|
f16762 |
# -verbose and -mapfile options.
|
|
|
f16762 |
for OPTION in $OPTIONS;do
|
|
|
f16762 |
# Remove anything after equal sign inside option.
|
|
|
f16762 |
OPTION=$(echo $OPTION | cut -d'=' -f1)
|
|
|
f16762 |
if [[ "$OPTION" =~ "-(mapfile|verbose)" ]];then
|
|
|
f16762 |
cli_printMessage "`eval_gettext "The \\\$OPTION option is already used."`"
|
|
|
f16762 |
cli_printMessage "$(caller)" "AsToKnowMoreLine"
|
|
|
f16762 |
fi
|
|
|
f16762 |
done
|
|
|
4c79b5 |
|
|
|
379ebf |
# Re-define 16 colors images default file name prefix using
|
|
|
379ebf |
# options as reference. This is useful to differenciate final
|
|
|
379ebf |
# files produced using Floyd-Steinberg dithering and final files
|
|
|
379ebf |
# which are not.
|
|
|
379ebf |
if [[ "$OPTIONS" =~ '-floyd' ]];then
|
|
|
379ebf |
PREFIX="${PREFIX}-floyd"
|
|
|
379ebf |
fi
|
|
|
379ebf |
|
|
|
2aae87 |
# Define motif's palette location.
|
|
|
6e2366 |
local PALETTES=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getThemeName)/Colors
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Define the Netpbm color palette used when reducing colors. This
|
|
|
4c79b5 |
# palette should be 16 colors based. For more information on this
|
|
|
4c79b5 |
# see the isolinux documentation.
|
|
|
4c79b5 |
local PALETTE_PPM=$PALETTES/syslinux.ppm
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Define hexadecimal color information used by ppmtolss16. Color
|
|
|
4c79b5 |
# information and order used on PALETTE_HEX and PALETTE_PPM should
|
|
|
4c79b5 |
# match exactly.
|
|
|
4c79b5 |
local PALETTE_HEX=$PALETTES/syslinux.hex
|
|
|
4c79b5 |
|
|
|
2aae87 |
# Print which palette of colors centos-art.sh script is using to
|
|
|
2aae87 |
# produce grub content. This is relevant in order to know if we
|
|
|
2aae87 |
# are using wether trunk or branches palette of colors.
|
|
|
2aae87 |
cli_printMessage "$PALETTE_PPM" 'AsPaletteLine'
|
|
|
2aae87 |
cli_printMessage "$PALETTE_HEX" 'AsPaletteLine'
|
|
|
2aae87 |
|
|
|
4c79b5 |
# Check syslinux's palettes existence: If there is no palette
|
|
|
15b1d2 |
# assume that this is the first time you are rendition syslinux
|
|
|
4c79b5 |
# images. If that is the case the script will provide you with the
|
|
|
4c79b5 |
# PNG format which should be used as base to produce (using GIMP)
|
|
|
4c79b5 |
# the .gpl palette. The .gpl palette information is used to
|
|
|
4c79b5 |
# produced (using GIMP) the colormap (.ppm) which is used to
|
|
|
4c79b5 |
# automate the syslinux's 16 colors image (syslinux-splash.png)
|
|
|
15b1d2 |
# rendition. If there is no palette available, do not apply color
|
|
|
4c79b5 |
# reduction, show a message, and continue.
|
|
|
e4d34a |
cli_checkFiles $PALETTE_PPM
|
|
|
e4d34a |
cli_checkFiles $PALETTE_HEX
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Create Netpbm superformat (PNM). PNM file is created from the
|
|
|
4c79b5 |
# PNG image rendered previously. PNM is a common point for image
|
|
|
4c79b5 |
# manipulation using Netpbm tools.
|
|
|
4c79b5 |
cli_printMessage "$FILE.pnm" "AsSavedAsLine"
|
|
|
4c79b5 |
pngtopnm -verbose \
|
|
|
4c79b5 |
< $FILE.png \
|
|
|
4c79b5 |
2>$FILE.log > $FILE.pnm
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Reduce colors. Here we use the Netpbm color $PALETTE_PPM to
|
|
|
4c79b5 |
# enforce the color position in the image index and the
|
|
|
4c79b5 |
# Floyd-Steinberg dithering in order to improve color reduction.
|
|
|
f16762 |
cli_printMessage "$FILE${PREFIX}.pnm" "AsSavedAsLine"
|
|
|
379ebf |
pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \
|
|
|
4c79b5 |
< $FILE.pnm \
|
|
|
f16762 |
2>>$FILE.log > $FILE${PREFIX}.pnm
|
|
|
f16762 |
|
|
|
4c79b5 |
# Create LSS16 image. As specified in isolinux documentation the
|
|
|
4c79b5 |
# background color should be indexed on position 0 and forground
|
|
|
4c79b5 |
# in position 7 (see /usr/share/doc/syslinux-X.XX/isolinux.doc).
|
|
|
4c79b5 |
# This order of colors is specified in $PALETTE_PPM and redefined
|
|
|
4c79b5 |
# here again for the LSS16 image format. Both $PALETTE_PPM and
|
|
|
4c79b5 |
# LSS16 color map redefinition ($PALETTE_HEX) should have the same
|
|
|
4c79b5 |
# colors and index order. PALETTE_HEX should return just one line
|
|
|
4c79b5 |
# with the color information as described in isolinux
|
|
|
4c79b5 |
# documentation (i.e #RRGGBB=0 #RRGGBB=1 ... [all values in the
|
|
|
4c79b5 |
# same line]).
|
|
|
f16762 |
cli_printMessage "$FILE${PREFIX}.lss" "AsSavedAsLine"
|
|
|
4c79b5 |
PALETTE_HEX=$(cat $PALETTE_HEX | tr "\n" ' ' | tr -s ' ')
|
|
|
4c79b5 |
ppmtolss16 $PALETTE_HEX \
|
|
|
f16762 |
< $FILE${PREFIX}.pnm \
|
|
|
4c79b5 |
2>>$FILE.log \
|
|
|
f16762 |
> $FILE${PREFIX}.lss
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Create the PPM image indexed to 16 colors. Also the colormap
|
|
|
4c79b5 |
# used in the LSS16 image is saved on $FILE.log; this is useful to
|
|
|
4c79b5 |
# verify the correct order of colors in the image index.
|
|
|
f16762 |
cli_printMessage "$FILE${PREFIX}.ppm" "AsSavedAsLine"
|
|
|
f16762 |
lss16toppm -map < $FILE${PREFIX}.lss \
|
|
|
4c79b5 |
2>>$FILE.log \
|
|
|
f16762 |
> $FILE${PREFIX}.ppm
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Create the 16 colors PNG image.
|
|
|
f16762 |
cli_printMessage "$FILE${PREFIX}.png" "AsSavedAsLine"
|
|
|
4c79b5 |
pnmtopng -verbose -palette=$PALETTE_PPM \
|
|
|
f16762 |
< $FILE${PREFIX}.pnm \
|
|
|
4c79b5 |
2>>$FILE.log \
|
|
|
f16762 |
> $FILE${PREFIX}.png
|
|
|
4c79b5 |
|
|
|
4c79b5 |
}
|