summaryrefslogtreecommitdiff
path: root/scripts/bin2png.sh
blob: 88726aaa81473c58e512bfdaa9d46e31f8f7d546 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh

FILE="$1"

PNM=${FILE/%bin/pnm}
PNG=${FILE/%bin/png}

fmt=$(echo $FILE | sed -e 's|.*-\([[:alnum:]]*\)-\([0-9]*x[0-9]*\).*.bin|\1|' | tr '[:lower:]' '[:upper:]')
size=$(echo $FILE | sed -e 's|.*-\([[:alnum:]]*\)-\([0-9]*x[0-9]*\).*.bin|\2|')

case $fmt in
	yuv*|yvu*)
		fmt=$(echo $fmt | tr 'M' 'P')
		;;
	nv*)
		fmt=$(echo $fmt | tr -d 'M')
		;;
	*rgb*)
		fmt=$(echo $fmt | tr -d 'AX')
		;;
esac

raw2rgbpnm -s $size -f $fmt $FILE $PNM && \
	convert $PNM $PNG
rm $PNM