| #!/bin/bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| function svg_convertPngToGrub { |
| |
| |
| local COLORS='14' |
| |
| |
| |
| |
| |
| local OPTIONS=$(render_getConfigOption "$ACTION" '2-') |
| |
| |
| |
| |
| for OPTION in $OPTIONS;do |
| |
| OPTION=$(echo -n $OPTION | cut -d'=' -f1) |
| if [[ "$OPTION" =~ "-(mapfile|verbose)" ]];then |
| cli_printMessage "`eval_gettext "The \\\"\\\$OPTION\\\" option is already used."`" --as-error-line |
| fi |
| done |
| |
| # Define file name prefix. |
| local PREFIX="-${COLORS}c" |
| |
| # Redefine file name prefix using options as reference. This is |
| # useful to differenciate final files produced using |
| # Floyd-Steinberg dithering and files which are not. |
| if [[ "$OPTIONS" =~ '-floyd' ]];then |
| PREFIX="${PREFIX}-floyd" |
| fi |
| |
| # Define logs' file. Log files are stored in the same place of |
| # images and are used to store output information produced by |
| # programs when the image files are built up. |
| local LOGS=${FILE}${PREFIX}.log |
| |
| # Define absolute path to GPL palette. This palettes should have |
| # 14 colors only. For more information on this see the GRUB's |
| # documentation. |
| local PALETTE_GPL=${MOTIF_DIR}/Palettes/grub.gpl |
| |
| # Verify GPL palette existence. If it doesn't exist copy the one |
| # provided by the design model through subversion (to keep track |
| # of the change) and expand translation markers in the copied |
| # instance. |
| if [[ ! -f $PALETTE_GPL ]];then |
| svn cp ${MODEL_BASEDIR}/${FLAG_THEME_MODEL}/Palettes/grub.gpl ${PALETTE_GPL} |
| cli_expandTMarkers ${PALETTE_GPL} |
| fi |
| |
| # Define absolute path to PPM palette. The PPM palette is built |
| # from source palette (PALETTE_GPL) and provides the color |
| # information understood by `ppmremap', the program used to |
| # produce images in a specific amount of colors. |
| local PALETTE_PPM=$(cli_getTemporalFile "grub.ppm") |
| |
| # Create image in Netpbm superformat (PNM). The PNM image file is |
| # created from the PNG image rendered previously as centos-art |
| # base-rendition output. The PNM image is an intermediate format |
| # used to manipulate images through Netpbm tools. |
| cli_printMessage "${FILE}.pnm" --as-savedas-line |
| pngtopnm -verbose \ |
| < ${FILE}.png 2>${LOGS} > ${FILE}.pnm |
| |
| # Print the path to GPL palette. |
| cli_printMessage "$PALETTE_GPL" --as-palette-line |
| |
| # Create PPM palette using GPL palette. |
| svg_convertGplToPpm "$PALETTE_GPL" "$PALETTE_PPM" "$COLORS" |
| |
| # Reduce colors as specified in PPM palette. Here we use the PPM |
| # palette to enforce the color position in the image index and the |
| # Floyd-Steinberg dithering in order to improve color reduction. |
| cli_printMessage "${FILE}${PREFIX}.ppm" --as-savedas-line |
| pnmremap -verbose -mapfile=$PALETTE_PPM $OPTIONS \ |
| < ${FILE}.pnm 2>>${LOGS} > ${FILE}${PREFIX}.ppm |
| |
| # Remove PPM palette. It is no longer needed. |
| if [[ -f ${PALETTE_PPM} ]];then |
| rm $PALETTE_PPM |
| fi |
| |
| # Create the 14 colors xpm.gz file. |
| cli_printMessage "${FILE}${PREFIX}.xpm.gz" --as-savedas-line |
| ppmtoxpm \ |
| < ${FILE}${PREFIX}.ppm 2>>${LOGS} > ${FILE}.xpm \ |
| && gzip --force ${FILE}.xpm \ |
| && mv ${FILE}.xpm.gz ${FILE}${PREFIX}.xpm.gz |
| |
| } |
| |