Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(451)

Unified Diff: scripts/newbitmaps/strings/text_to_bmp

Issue 6598046: Add stuff to support new bitmap format. (Closed) Base URL: http://git.chromium.org/git/vboot_reference.git@master
Patch Set: Agree to all changes. PTAL. Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: scripts/newbitmaps/strings/text_to_bmp
diff --git a/scripts/newbitmaps/strings/text_to_bmp b/scripts/newbitmaps/strings/text_to_bmp
new file mode 100755
index 0000000000000000000000000000000000000000..e0c77b99810c9e221bd99fae16411f1ba4e8cc7a
--- /dev/null
+++ b/scripts/newbitmaps/strings/text_to_bmp
@@ -0,0 +1,53 @@
+#!/bin/bash -e
+# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# Render a text file into a bitmap.
+#
+
+# Image parameters
+bg='#607c91'
+bluecolor='#9ccaec'
+bluefont="Helvetica-Narrow"
+bluepointsize=19
+whitefont="Helvetica-Narrow"
+whitepointsize=30
+
+
+tmpdir=$(mktemp -d /tmp/tmp.bmp.XXXXXX)
+trap "rm -rf $tmpdir" EXIT
+label_file="${tmpdir}/label.txt"
+
+for txtfile in $*; do
+ bmpfile="${txtfile%.*}".bmp
+ perl -p -e 'BEGIN{ $/=undef; }' \
+ -e 's/^\s+//s;' -e 's/\s+$//s;' \
+ "$txtfile" > "$label_file"
+
+ case "$txtfile" in
+ *.txt)
+ convert \
+ -background "$bg" -fill "$bluecolor" \
+ -font "$bluefont" -pointsize "$bluepointsize" \
+ -bordercolor "$bg" -border 0x1 -gravity Center \
+ label:'@'"$label_file" \
+ -colors 256 -compress none -alpha off \
+ "$bmpfile"
+ echo "wrote $bmpfile"
+ ;;
+ *.TXT)
+ convert \
+ -background "$bg" -fill "white" \
+ -font "$whitefont" -pointsize "$whitepointsize" \
+ -bordercolor "$bg" -border 0x10 -gravity Center \
+ label:'@'"$label_file" \
+ -colors 256 -compress none -alpha off \
+ "$bmpfile"
+ echo "wrote $bmpfile"
+ ;;
+ *)
+ echo "Ignoring $txtfile. Filname should end with .txt or .TXT"
+ ;;
+ esac
+done

Powered by Google App Engine
This is Rietveld 408576698