2023-11-17 12:30:24 -08:00
|
|
|
#!/bin/bash
|
2023-11-17 14:12:46 -08:00
|
|
|
usage() {
|
|
|
|
cat << EOF
|
|
|
|
$0 usage:
|
|
|
|
-p|--use-program <program path>
|
|
|
|
Uses the specified already-compiled binary rather than compiling manually
|
|
|
|
-i|--input-image <image path>
|
|
|
|
Adds an image input at the specified path to the image list.
|
|
|
|
-b|--output-bpp <bpp>
|
|
|
|
Adds a bitdepth to the list to test with
|
2023-11-18 12:55:26 -08:00
|
|
|
-r|--resize <width>x<height>
|
2023-11-17 14:12:46 -08:00
|
|
|
Adds a resize to the list to test with
|
|
|
|
--no-reverse
|
|
|
|
Disables reverse operation testing
|
|
|
|
--no-dither
|
|
|
|
Disables dithering testing
|
2023-11-18 12:55:26 -08:00
|
|
|
-d|--debug
|
|
|
|
Use debug flags with the converter program.
|
2023-11-17 14:12:46 -08:00
|
|
|
-n|--no-defaults
|
|
|
|
Disables default settings
|
|
|
|
EOF
|
|
|
|
exit 1
|
|
|
|
}
|
2023-11-17 12:30:24 -08:00
|
|
|
oldpwd="$(pwd)"
|
|
|
|
cd "$(dirname "$0")"
|
2023-11-17 14:12:46 -08:00
|
|
|
converter="./builddir/b16converter"
|
|
|
|
prebuilt=0
|
|
|
|
images=()
|
2023-11-18 12:55:26 -08:00
|
|
|
bpps=()
|
2023-11-17 14:12:46 -08:00
|
|
|
resize=()
|
|
|
|
enable_defaults=1
|
|
|
|
dither=1
|
|
|
|
reverse=1
|
2023-11-21 19:15:08 -08:00
|
|
|
enable_compression=1
|
2023-11-17 14:12:46 -08:00
|
|
|
enable_reverse=1
|
|
|
|
enable_dither=1
|
2023-11-18 12:55:26 -08:00
|
|
|
debug_flags=""
|
2023-11-17 12:30:24 -08:00
|
|
|
outdir="testout"
|
2023-11-21 19:15:08 -08:00
|
|
|
OPTIONS=$(getopt -o "b:hp:i:r:no:d:" --long "help,use-program:,input-image:,output-bpp:,resize:,no-defaults,output-dir:,debug:,no-reverse,no-dither,no-compress" -- "$@")
|
2023-11-17 14:12:46 -08:00
|
|
|
if [ $? != 0 ]; then
|
2023-11-18 12:55:26 -08:00
|
|
|
echo "Getopt error."
|
2023-11-17 14:12:46 -08:00
|
|
|
usage
|
|
|
|
fi
|
|
|
|
eval set -- "$OPTIONS"
|
|
|
|
while [ -n "$1" ]; do
|
|
|
|
case "$1" in
|
|
|
|
-o|--output-dir)
|
|
|
|
outdir="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
-h|--help)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
-p|--use-program)
|
|
|
|
converter="$2"
|
|
|
|
prebuilt=1
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
-i|--input-image)
|
|
|
|
images+="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
-b|--output-bpp)
|
|
|
|
bpp+="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
-r|--resize)
|
2023-11-18 12:55:26 -08:00
|
|
|
resize+="$2"
|
2023-11-17 14:12:46 -08:00
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
-n|--no-defaults)
|
|
|
|
enable_defaults=0
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--no-reverse)
|
|
|
|
enable_reverse=0
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--no-dither)
|
|
|
|
enable_dither=0
|
|
|
|
shift
|
|
|
|
;;
|
2023-11-21 19:15:08 -08:00
|
|
|
--no-compress)
|
|
|
|
enable_compression=0
|
|
|
|
shift
|
|
|
|
;;
|
2023-11-18 12:55:26 -08:00
|
|
|
-d|--debug)
|
|
|
|
debug_flags="${debug_flags}$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2023-11-17 14:12:46 -08:00
|
|
|
--)
|
|
|
|
shift
|
|
|
|
break
|
|
|
|
;;
|
2023-11-18 12:55:26 -08:00
|
|
|
*)
|
|
|
|
echo "Invalid option: $0"
|
2023-11-17 14:12:46 -08:00
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
if [ $enable_defaults -ne 0 ]; then
|
|
|
|
images+=("TEST.png" "PACK.png")
|
2023-11-18 12:55:26 -08:00
|
|
|
bpps+=(1 2 4 8)
|
2023-11-17 14:12:46 -08:00
|
|
|
resize+=("8x8" "16x16" "32x32" "64x64" "320x240" "640x480")
|
|
|
|
fi
|
|
|
|
if [ $prebuilt -eq 0 ]; then
|
|
|
|
meson setup builddir
|
|
|
|
meson compile -C builddir || exit $?
|
|
|
|
fi
|
|
|
|
mkdir -p "$outdir"
|
2023-11-18 12:55:26 -08:00
|
|
|
run() {
|
|
|
|
printf "Running: %s\n" "$*"
|
|
|
|
"$@"
|
|
|
|
}
|
2023-11-17 12:30:24 -08:00
|
|
|
for img in "${images[@]}"; do
|
2023-11-18 12:55:26 -08:00
|
|
|
for bpp in "${bpps[@]}"; do
|
2023-11-17 14:12:46 -08:00
|
|
|
for size in "${resize[@]}"; do
|
2023-11-21 19:15:08 -08:00
|
|
|
for compressflag in -compress ""; do
|
|
|
|
width="$(echo -n "$size" | cut -dx -f1)"
|
|
|
|
height="$(echo -n "$size" | cut -dx -f2)"
|
|
|
|
name="$(basename "$img" | sed 's/\.png$//')"
|
|
|
|
name="$(printf "%s.%sP.%sB" "$name" "$width" "$bpp")"
|
|
|
|
extraflags=()
|
|
|
|
if [ -n "$compressflag" ]; then
|
|
|
|
if [ $enable_compression -eq 0 ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
extraflags+=( "$compressflag" )
|
|
|
|
name+=".C"
|
|
|
|
fi
|
|
|
|
run "$converter" "${extraflags[@]}" -in "$img" -out "$outdir/$name.BMX" -bpp "$bpp" -resize "$width" "$height" -border 15 0 15 -debug "$debug_flags"
|
2023-11-17 14:12:46 -08:00
|
|
|
if [ $enable_dither -ne 0 ]; then
|
2023-11-21 19:15:08 -08:00
|
|
|
run "$converter" "${extraflags[@]}" -in "$img" -out "$outdir/$name.D.BMX" -bpp "$bpp" -resize "$width" "$height" -dither -border 15 0 15 -debug "$debug_flags"
|
|
|
|
fi
|
|
|
|
if [ $enable_reverse -ne 0 ]; then
|
|
|
|
run "$converter" "${extraflags[@]}" -reverse -in "$outdir/$name.BMX" -out "$outdir/$name.PNG" -resize "$width" "$height" -debug "$debug_flags"
|
|
|
|
if [ $enable_dither -ne 0 ]; then
|
|
|
|
run "$converter" "${extraflags[@]}" -reverse -in "$outdir/$name.D.BMX" -out "$outdir/$name.D.PNG" -resize "$width" "$height" -dither -debug "$debug_flags"
|
|
|
|
fi
|
2023-11-17 14:12:46 -08:00
|
|
|
fi
|
2023-11-21 19:15:08 -08:00
|
|
|
done
|
2023-11-17 12:30:24 -08:00
|
|
|
done
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
cd "$oldpwd"
|