|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
ab1d67 |
# render_doSyslinux.sh -- This function provides post-rendition
|
|
|
8fc04a |
# action used to produce LSS16 images, the images used by isolinux.
|
|
|
8fc04a |
#
|
|
|
8fc04a |
# This function uses three different formats to handle the same color
|
|
|
8fc04a |
# information. Initially, the color information is defined with GIMP
|
|
|
8fc04a |
# (The GNU Image Manipulation Program) as a palette of color. This
|
|
|
8fc04a |
# palette of colors contains 16 colors only and is saved in a file
|
|
|
8fc04a |
# named `syslinux.gpl.
|
|
|
8fc04a |
#
|
|
|
8fc04a |
# The `syslinux.gpl' file is used to build two other files: the
|
|
|
8fc04a |
# `syslinux.ppm' file and the `syslinux.hex' file. The `syslinux.ppm'
|
|
|
8fc04a |
# file is used to reduce a full color PNG image to the amount of
|
|
|
8fc04a |
# colors it specifies (i.e., 16 colors). Later, with the 16 color
|
|
|
8fc04a |
# image already created, the `syslinux.hex' file is used to build the
|
|
|
8fc04a |
# LSS16 image.
|
|
|
8fc04a |
#
|
|
|
8fc04a |
# In order to produce images in LSS16 format correctly, it is needed
|
|
|
8fc04a |
# that both the `syslinux.ppm' and `syslinux.hex' files contain the
|
|
|
8fc04a |
# same color information. This is, both `syslinux.ppm' and
|
|
|
8fc04a |
# `syslinux.hex' shoud represent the same color values and the same
|
|
|
8fc04a |
# color index.
|
|
|
8fc04a |
#
|
|
|
8fc04a |
# This function save you the work of preparing both `syslinux.ppm' and
|
|
|
8fc04a |
# `syslinux.hex'. Instead, you only need to prepare the `syslinux.gpl'
|
|
|
8fc04a |
# file with the color information you want to produce images.
|
|
|
8fc04a |
#
|
|
|
8fc04a |
# In order for this function to work, the `syslinux.gpl' file should
|
|
|
8fc04a |
# have a format similar to the following:
|
|
|
8fc04a |
#
|
|
|
fa95b1 |
# GIMP Palette
|
|
|
fa95b1 |
# Name: TreeFlower-4-Syslinux
|
|
|
fa95b1 |
# Columns: 16
|
|
|
fa95b1 |
# #
|
|
|
fa95b1 |
# 10 22 40 0a1628
|
|
|
fa95b1 |
# 9 28 52 091c34
|
|
|
fa95b1 |
# 16 34 63 10223f
|
|
|
fa95b1 |
# 20 37 67 142543
|
|
|
fa95b1 |
# 15 39 74 0f274a
|
|
|
fa95b1 |
# 12 45 85 0c2d55
|
|
|
fa95b1 |
# 20 43 78 142b4e
|
|
|
fa95b1 |
# 255 255 255 ffffff
|
|
|
fa95b1 |
# 21 51 95 15335f
|
|
|
fa95b1 |
# 41 52 70 293446
|
|
|
fa95b1 |
# 32 76 141 204c8d
|
|
|
fa95b1 |
# 77 90 107 4d5a6b
|
|
|
fa95b1 |
# 143 154 167 8f9aa7
|
|
|
fa95b1 |
# 128 179 255 80b3ff
|
|
|
fa95b1 |
# 194 200 202 c2c8ca
|
|
|
fa95b1 |
# 231 241 255 e7f1ff
|
|
|
4c79b5 |
#
|
|
|
2d3646 |
# 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.
|
|
|
fa95b1 |
#
|
|
|
74a058 |
# This program is distributed in the hope that it will be useful, but
|
|
|
74a058 |
# 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
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
7ac5a5 |
#
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
418249 |
# $Id$
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
4c79b5 |
|
|
|
ab1d67 |
function render_doSyslinux {
|
|
|
4c79b5 |
|
|
|
8fc04a |
# Define number of colors the images will be produced on.
|
|
|
8fc04a |
local COLOR_NUMBER='16'
|
|
|
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.
|
|
|
ab1d67 |
local OPTIONS=$(render_getConfigOption "$ACTION" '2-')
|
|
|
f16762 |
|
|
|
f16762 |
# Check options passed to action. This is required in order to
|
|
|
8fc04a |
# aviod using options already used 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."`"
|
|
|
eee226 |
cli_printMessage "${FUNCDIRNAM}" "AsToKnowMoreLine"
|
|
|
f16762 |
fi
|
|
|
f16762 |
done
|
|
|
4c79b5 |
|
|
|
8fc04a |
# Define default file name prefix for 16 colors images.
|
|
|
8fc04a |
local PREFIX="-${COLOR_NUMBER}c"
|
|
|
8fc04a |
|
|
|
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 |
|
|
|
8fc04a |
# Define theme-specific palettes directory.
|
|
|
4478a0 |
local PALETTES=$(cli_getRepoTLDir)/Identity/Themes/Motifs/$(cli_getPathComponent '--theme')/Palettes
|
|
|
8c9526 |
|
|
|
8fc04a |
# Define absolute path to GPL palette. The GPL palette defines the
|
|
|
8fc04a |
# color information used to build syslinux images. This palette
|
|
|
8fc04a |
# should be set to 16 colors and, as specified in isolinux
|
|
|
8fc04a |
# documentation, the background color should be indexed on
|
|
|
8fc04a |
# position 0 and the forground in position 7 (see
|
|
|
8fc04a |
# /usr/share/doc/syslinux-X.XX/isolinux.doc, for more
|
|
|
8fc04a |
# information.)
|
|
|
8fc04a |
local PALETTE_GPL=${PALETTES}/syslinux.gpl
|
|
|
8fc04a |
|
|
|
8fc04a |
# Verify GPL palette existence.
|
|
|
8fc04a |
cli_checkFiles $PALETTE_GPL 'f'
|
|
|
8fc04a |
|
|
|
8fc04a |
# Define absolute path to PPM palette. The PPM palette is built
|
|
|
8fc04a |
# from source palette (PALETTE_GPL) and provides the color
|
|
|
8fc04a |
# information understood by `ppmremap', the program used to
|
|
|
8fc04a |
# produce images in a specific amount of colors.
|
|
|
8fc04a |
local PALETTE_PPM=$(cli_getTemporalFile "syslinux.ppm")
|
|
|
8fc04a |
|
|
|
8fc04a |
# Define the HEX palette. The HEX palette is built from source
|
|
|
8fc04a |
# palette (PALETTE_GPL) and provides the color information in the
|
|
|
8fc04a |
# format understood by `ppmtolss16', the program used to produce
|
|
|
8fc04a |
# images in LSS16 format. The HEX palette stores just one line
|
|
|
8fc04a |
# with the color information as described in isolinux
|
|
|
8fc04a |
# documentation (i.e #RRGGBB=0 #RRGGBB=1 ... [all values in the
|
|
|
8fc04a |
# same line])
|
|
|
8fc04a |
local PALETTE_HEX=$(cli_getTemporalFile "syslinux.hex")
|
|
|
8fc04a |
|
|
|
8fc04a |
# Create image in Netpbm superformat (PNM). The PNM image file is
|
|
|
8fc04a |
# created from the PNG image rendered previously as centos-art
|
|
|
8fc04a |
# base-rendition output. The PNM image is an intermediate format
|
|
|
8fc04a |
# used to manipulate images through Netpbm tools.
|
|
|
9b4d7d |
cli_printMessage "${FILE}.pnm" "AsSavedAsLine"
|
|
|
9b4d7d |
pngtopnm -verbose \
|
|
|
9b4d7d |
< ${FILE}.png 2>${FILE}.log > ${FILE}.pnm
|
|
|
8fc04a |
|
|
|
8fc04a |
# Print the path to GPL palette.
|
|
|
8fc04a |
cli_printMessage "$PALETTE_GPL" 'AsPaletteLine'
|
|
|
8fc04a |
|
|
|
8fc04a |
# Create PPM palette using GPL palette.
|
|
|
8fc04a |
render_convertGplToPpm "$PALETTE_GPL" "$PALETTE_PPM" "$COLOR_NUMBER"
|
|
|
8fc04a |
|
|
|
8fc04a |
# Create HEX palette using GPL palette.
|
|
|
8fc04a |
render_convertGplToHex "$PALETTE_GPL" "$PALETTE_HEX" "$COLOR_NUMBER"
|
|
|
8fc04a |
|
|
|
8fc04a |
# Reduce colors as specified in PPM palette. Here we use the PPM
|
|
|
8fc04a |
# palette to enforce the color position in the image index and the
|
|
|
4c79b5 |
# Floyd-Steinberg dithering in order to improve color reduction.
|
|
|
9b4d7d |
cli_printMessage "${FILE}${PREFIX}.pnm" "AsSavedAsLine"
|
|
|
379ebf |
pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \
|
|
|
9b4d7d |
< ${FILE}.pnm 2>> ${FILE}.log > ${FILE}${PREFIX}.pnm
|
|
|
f16762 |
|
|
|
8fc04a |
# Create LSS16 image.
|
|
|
9b4d7d |
cli_printMessage "${FILE}${PREFIX}.lss" "AsSavedAsLine"
|
|
|
8fc04a |
ppmtolss16 $(cat $PALETTE_HEX) \
|
|
|
9b4d7d |
< ${FILE}${PREFIX}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.lss
|
|
|
4c79b5 |
|
|
|
8fc04a |
# Remove HEX palette. It is no longer needed.
|
|
|
8fc04a |
if [[ -f ${PALETTE_HEX} ]];then
|
|
|
8fc04a |
rm $PALETTE_HEX
|
|
|
8fc04a |
fi
|
|
|
8fc04a |
|
|
|
4c79b5 |
# Create the PPM image indexed to 16 colors. Also the colormap
|
|
|
9b4d7d |
# 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.
|
|
|
9b4d7d |
cli_printMessage "${FILE}${PREFIX}.ppm" "AsSavedAsLine"
|
|
|
9b4d7d |
lss16toppm -map \
|
|
|
9b4d7d |
< ${FILE}${PREFIX}.lss 2>>${FILE}.log > ${FILE}${PREFIX}.ppm
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Create the 16 colors PNG image.
|
|
|
9b4d7d |
cli_printMessage "${FILE}${PREFIX}.png" "AsSavedAsLine"
|
|
|
4c79b5 |
pnmtopng -verbose -palette=$PALETTE_PPM \
|
|
|
9b4d7d |
< ${FILE}${PREFIX}.pnm 2>>${FILE}.log > ${FILE}${PREFIX}.png
|
|
|
4c79b5 |
|
|
|
8fc04a |
# Remove PPM palette. It is no longer needed.
|
|
|
8fc04a |
if [[ -f ${PALETTE_PPM} ]];then
|
|
|
8fc04a |
rm $PALETTE_PPM
|
|
|
8fc04a |
fi
|
|
|
8fc04a |
|
|
|
4c79b5 |
}
|