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

4c79b5
#!/bin/bash
4c79b5
#
4c79b5
# render_doIdentityImageGrub.sh -- This function provides
4c79b5
# post-rendering action used to produce GRUB 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_doIdentityImageGrub.sh 71 2010-09-18 05:41:11Z al $
4c79b5
# ----------------------------------------------------------------------
4c79b5
4c79b5
function render_doIdentityImageGrub {
4c79b5
4c79b5
    local FILE=$1
4c79b5
4c79b5
    # Define Motif's palette location. We do this relatively.
ca9597
    local PALETTES=/home/centos/artwork/trunk/Identity/Themes/Motifs/$(cli_getThemeName)/Colors
4c79b5
4c79b5
    # Define the Netpbm color palettes used when reducing colors.
4c79b5
    # These palettes should be 14 colors based. For more information
4c79b5
    # on this see the GRUB's documentation.
4c79b5
    local PALETTE_PPM=$PALETTES/grub.ppm
4c79b5
4c79b5
    # Check GRUB's palettes existence:  If there is no palette assume
4c79b5
    # that this is the first time you are rendering GRUB images. If
4c79b5
    # that is the case the script will provide you with the PNG format
4c79b5
    # which should be used as base to produce (using GIMP) the .gpl
4c79b5
    # palette.  The .gpl palette information is used to produced
4c79b5
    # (using GIMP) the colormap (.ppm) which is used to automate the
4c79b5
    # GRUB's 14 colors image (splash.png) rendering.  If there is no
4c79b5
    # palette available, do not apply color reduction, show a message,
4c79b5
    # and continue.
e4d34a
    cli_checkFiles $PALETTE_PPM
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 \
4c79b5
        > $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-14c.ppm" "AsSavedAsLine"
4c79b5
    pnmremap -verbose -floyd -mapfile=$PALETTE_PPM \
4c79b5
        < $FILE.pnm \
4c79b5
        2>>$FILE.log \
4c79b5
        > $FILE-14c.ppm
4c79b5
4c79b5
    # Create the XPM.GZ file. This is the file we put at
4c79b5
    # /boot/grub/splash.xpm.gz.
4c79b5
    cli_printMessage "$FILE.xpm.gz" "AsSavedAsLine"
4c79b5
    ppmtoxpm \
4c79b5
        < $FILE-14c.ppm \
4c79b5
        2>>$FILE.log \
4c79b5
        > $FILE.xpm \
4c79b5
        && gzip --force $FILE.xpm
4c79b5
   
4c79b5
}
4c79b5