diff options
| author | spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> | 2021-09-12 19:39:02 +0200 |
|---|---|---|
| committer | spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> | 2021-09-12 19:39:02 +0200 |
| commit | c6548f077282f871bc22bd05595d3a1139f50a80 (patch) | |
| tree | b5771fabdfd86fa2e2076ee08029d358c92f017d /cpack/convert_images.sh | |
| parent | ffa679d4d24b891cb59aba10946368f2ec00c391 (diff) | |
| download | psn00bsdk-c6548f077282f871bc22bd05595d3a1139f50a80.tar.gz | |
Added preliminary files for CMake/CPack support
Diffstat (limited to 'cpack/convert_images.sh')
| -rw-r--r-- | cpack/convert_images.sh | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/cpack/convert_images.sh b/cpack/convert_images.sh new file mode 100644 index 0000000..3816dec --- /dev/null +++ b/cpack/convert_images.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# This script generates Windows bitmaps from the SVGs in this directory. The +# bitmaps are displayed by the NSIS installers generated using CPack. Inkscape +# and ImageMagick must be installed for this script to work. + +INDEXED_SIZES=(16 24 32 48) +RGB_ONLY_SIZES=(64 96 128 256) +DITHER_OPTIONS="-dither riemersma" +OUTPUT_OPTIONS="+compress -strip" + +svg_to_bitmap() { + inkscape -z -e rgb.png $1 + + # There seems to be no way to tell ImageMagick to generate an 8-bit indexed + # BMP directly, so the image has to be converted to indexed PNG first. NSIS + # seems to reject all BMP versions other than "bmp3". + convert $DITHER_OPTIONS -colors 256 +remap rgb.png png8:i8.png + convert i8.png $OUTPUT_OPTIONS bmp3:$2 + rm -f rgb.png i8.png +} + +# https://stackoverflow.com/a/52636645 +svg_to_icon() { + for size in ${INDEXED_SIZES[@]} ${RGB_ONLY_SIZES[@]}; do + inkscape -z -e $size.png -w $size -h $size $1 + done + + # Windows expects some of the smaller sizes to be available in 4- and 8-bit + # indexed color formats, as well as RGB. + for size in ${INDEXED_SIZES[@]}; do + convert $DITHER_OPTIONS -colors 256 +remap $size.png png8:$size-i8.png + convert $DITHER_OPTIONS -colors 16 +remap $size.png png8:$size-i4.png + done + + icons="${INDEXED_SIZES[@]/%/.png} ${INDEXED_SIZES[@]/%/-i8.png} ${INDEXED_SIZES[@]/%/-i4.png} ${RGB_ONLY_SIZES[@]/%/.png}" + convert $icons $OUTPUT_OPTIONS $2 + rm -f $icons +} + +rm -f *.ico *.bmp + +svg_to_icon icon.svg icon.ico +svg_to_icon uninstall.svg uninstall.ico +svg_to_bitmap nsis_banner.svg nsis_banner.bmp +svg_to_bitmap nsis_header.svg nsis_header.bmp |
