Blame Scripts/Bash/Functions/Render/render_doIdentityImageSyslinux.sh

4c79b5
#!/bin/bash
4c79b5
#
4c79b5
# render_doIdentityImageSyslinux.sh -- This function provides
4c79b5
# post-rendering action used to produce syslinux images.
4c79b5
#
4c79b5
# Copyright (C) 2009-2010 Alain Reguera Delgado
4c79b5
# 
4c79b5
# This program is free software; you can redistribute it and/or modify
4c79b5
# it under the terms of the GNU General Public License as published by
4c79b5
# the Free Software Foundation; either version 2 of the License, or
4c79b5
# (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
# ----------------------------------------------------------------------
4c79b5
# $Id: render_doIdentityImageSyslinux.sh 71 2010-09-18 05:41:11Z al $
4c79b5
# ----------------------------------------------------------------------
4c79b5
4c79b5
function render_doIdentityImageSyslinux {
4c79b5
4c79b5
    local FILE=$1
4c79b5
4c79b5
    # Define Motif's palette location. We do this relatively.
ca9597
    local
ca9597
    PALETTES=/home/centos/artwork/trunk/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
4c79b5
    # Check syslinux's palettes existence:  If there is no palette
4c79b5
    # assume that this is the first time you are rendering 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)
4c79b5
    # rendering.  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.
4c79b5
    cli_printMessage "$FILE-16c.pnm" "AsSavedAsLine"
4c79b5
    pnmremap -verbose -floyd -mapfile=$PALETTE_PPM \
4c79b5
        < $FILE.pnm \
4c79b5
        2>>$FILE.log > $FILE-16c.pnm
4c79b5
      
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]).
4c79b5
    cli_printMessage "$FILE.lss" "AsSavedAsLine"
4c79b5
    PALETTE_HEX=$(cat $PALETTE_HEX | tr "\n" ' ' | tr -s ' ')
4c79b5
    ppmtolss16 $PALETTE_HEX \
4c79b5
        < $FILE-16c.pnm \
4c79b5
        2>>$FILE.log \
4c79b5
        > $FILE.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.
4c79b5
    cli_printMessage "$FILE-16c.ppm" "AsSavedAsLine"
4c79b5
    lss16toppm -map < $FILE.lss \
4c79b5
       2>>$FILE.log \
4c79b5
       > $FILE.ppm
4c79b5
      
4c79b5
    # Create the 16 colors PNG image.
4c79b5
    cli_printMessage "$FILE-16c.png" "AsSavedAsLine"
4c79b5
    pnmtopng -verbose -palette=$PALETTE_PPM \
4c79b5
       < $FILE-16c.pnm \
4c79b5
       2>>$FILE.log \
4c79b5
       > $FILE-16c.png
4c79b5
   
4c79b5
}