summaryrefslogtreecommitdiff
path: root/scripts/bin2png.sh
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2016-12-01 21:31:46 +0000
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2017-02-13 20:43:48 +0200
commit9e023de20265fc4211f3b34d45c5dfc9f526de3f (patch)
tree541e258de2cc3ddaf0284d9e337c36c5e18f5985 /scripts/bin2png.sh
parent2b923a64ce11f4dc4e12cc024ce9b30b09b162a4 (diff)
scripts: Provide bin2png.sh helper
Identify the size and format from the test output filename, and pass to raw2rgbpnm for conversion to a PNM file. From there we can convert easily to a PNG output file. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'scripts/bin2png.sh')
-rwxr-xr-xscripts/bin2png.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/bin2png.sh b/scripts/bin2png.sh
new file mode 100755
index 0000000..88726aa
--- /dev/null
+++ b/scripts/bin2png.sh
@@ -0,0 +1,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