#!/bin/bash
# *****************************************************************************
# @author CsHeng
# @2015.10.23
# 转化一个大的icon成多个不同分辨率的icon
#
# 选项：
#     -i input icon path
#     -o resource path, exp: app/src/main/res
#
# *****************************************************************************

CWD=$(cd "$(dirname "$0")"; pwd)
INPUT="${CWD}/../appicon.png"
OUTPUT="${CWD}/../frameworks/runtime-src/proj.android/src/main/res"
ICON_FILE="ic_launcher.png"
while getopts "i:o:" arg
do
	case ${arg} in
		i)
		INPUT=${OPTARG}
		;;
		o)
		OUTPUT=${OPTARG}
		;;
		?)
		echo "unknown argument"
		exit 1;
		;;
		esac
done

#DIR=(drawable-ldpi drawable-mdpi drawable-hdpi drawable-xhdpi drawable-xxhdpi drawable-xxxhdpi)
DIR=(mipmap-ldpi mipmap-mdpi mipmap-hdpi mipmap-xhdpi mipmap-xxhdpi mipmap-xxxhdpi)
RESOLUTION=( 36x36 48x48 72x72 96x96 144x144 192x192 )

for((i=0;i<${#DIR[@]};i++))
do
	mkdir -p ${OUTPUT}/${DIR[$i]}
	convert ${INPUT} -resize ${RESOLUTION[$i]} ${OUTPUT}/${DIR[$i]}/${ICON_FILE}
done
