From 2187cdfb351be45ac168779e59cb08065214599f Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Tue, 26 Oct 2010 11:37:24 -0700 Subject: [PATCH] Change bitmap scripts for two-color/two-font text labeling. Change-Id: I4620966554ca26ea91b01e65fd441c9c09db2a83 BUG=chrome-os-parter:792 TEST=none As with every previous change to the BIOS bitmaps, you'll have to 1) get a new factory-install shim with the bitmaps embedded 2) run the factory-install shim to change the screens on the device 3) boot in developer and/or recovery mode to see the screens There is no direct test for this particular bug alone. Review URL: http://codereview.chromium.org/4158003 --- scripts/bitmaps/make_bmp_images.sh | 61 +++++++++++++------ scripts/bitmaps/makelines | 41 +++++++++++++ scripts/bitmaps/originals/DeveloperBmp.txt | 22 +------ scripts/bitmaps/originals/RecoveryBmp.txt | 21 +------ .../originals/RecoveryMissingOSBmp.txt | 24 ++------ scripts/bitmaps/originals/RecoveryNoOSBmp.txt | 21 +------ 6 files changed, 95 insertions(+), 95 deletions(-) create mode 100755 scripts/bitmaps/makelines diff --git a/scripts/bitmaps/make_bmp_images.sh b/scripts/bitmaps/make_bmp_images.sh index 3a163c1d59..dbc08dac73 100755 --- a/scripts/bitmaps/make_bmp_images.sh +++ b/scripts/bitmaps/make_bmp_images.sh @@ -11,12 +11,18 @@ # to the full screen size. # + + + # Require one arg if [ $# -ne "1" ]; then - echo "Usage: $(basename $0) URL" 1>&2 + echo "Usage: $(basename $0) MODEL" 1>&2 exit 1 fi -url=$1 +MODEL=$1 + +# Default URL +URL='http://google.com/chromeos/recovery' # Image parameters @@ -24,8 +30,11 @@ geom_orig='1366x800' geom_crop_a='1366x768' geom_crop_b='1280x800' geom_final='800x600!' -font="Helvetica-Narrow" -pointsize=30 +bluecolor='#9ccaec' +bluefont="Helvetica-Narrow" +bluepointsize=30 +whitefont="Helvetica-Narrow" +whitepointsize=48 # Temporary files @@ -37,6 +46,7 @@ img_crop_b="${tmpdir}/img_crop_b.bmp" img_txt_a="${tmpdir}/img_txt_a.bmp" img_txt_b="${tmpdir}/img_txt_b.bmp" label_file="${tmpdir}/label.txt" +label_img="${tmpdir}/label.bmp" # Output directories thisdir=$(readlink -e $(dirname $0)) @@ -81,18 +91,35 @@ function process_one_file { # Add the labels in if [ -r "$txt_file" ]; then - # Replace all '$URL' in the URL in the text file with the real url - perl -p \ - -e 'BEGIN {$/ = undef; $url = shift; }' \ - -e 's/\s+$/\n/gs; s/\$URL/$url/gs;' \ - "$url" "$txt_file" > "$label_file" - # Render it - convert "$img_crop_a" -fill white \ - -font "$font" -pointsize "$pointsize" -interline-spacing 5 \ - -gravity south -annotate '+0+0' '@'"$label_file" "$img_txt_a" - convert "$img_crop_b" -fill white \ - -font "$font" -pointsize "$pointsize" -interline-spacing 5 \ - -gravity south -annotate '+0+0' '@'"$label_file" "$img_txt_b" + # The only way to change font and color in multiline text is to split each + # line into a separate image and then composite them together. Ugh. + # First, split each input line into a separate file. + "${thisdir}/makelines" -u "$URL" -m "$MODEL" -d "$tmpdir" "$txt_file" + # Convert each line file into an image file. + for txtfile in ${tmpdir}/linetxt_*; do + case "$txtfile" in + *.txt) + convert \ + -background "$bg" -fill "$bluecolor" \ + -font "$bluefont" -pointsize "$bluepointsize" \ + -bordercolor "$bg" -border 0x1 \ + label:'@'"$txtfile" "${txtfile%.*}".bmp + ;; + *.TXT) + convert \ + -background "$bg" -fill "white" \ + -font "$whitefont" -pointsize "$whitepointsize" \ + -bordercolor "$bg" -border 0x10 \ + label:'@'"$txtfile" "${txtfile%.*}".bmp + ;; + esac + done + # Now bash them all together to make one image. + convert -background "$bg" -gravity center ${tmpdir}/linetxt_*.bmp \ + label:'\n\n\n\n' -append "$label_img" + # Finally, layer the label image on top of the original. + composite "$label_img" -gravity south "$img_crop_a" "$img_txt_a" + composite "$label_img" -gravity south "$img_crop_b" "$img_txt_b" else mv "$img_crop_a" "$img_txt_a" mv "$img_crop_b" "$img_txt_b" @@ -110,6 +137,6 @@ for file in originals/*.gif; do done # Zip up the bitmaps -nicename=${url// /_} +nicename=${MODEL// /_} (cd "$outdir_a" && zip -qr "${thisdir}/out_${nicename}__${geom_crop_a}.zip" *) (cd "$outdir_b" && zip -qr "${thisdir}/out_${nicename}__${geom_crop_b}.zip" *) diff --git a/scripts/bitmaps/makelines b/scripts/bitmaps/makelines new file mode 100755 index 0000000000..68e42f4d20 --- /dev/null +++ b/scripts/bitmaps/makelines @@ -0,0 +1,41 @@ +#!/usr/bin/perl + +use strict; +our $opt_u = 'http://www.chromium.org'; +our $opt_m = 'Unsupported Prototype 0000'; +our $opt_d = '.'; + +use File::Basename; +my $progdir = dirname($0); +my $prog = basename($0); + +use Getopt::Std; +my $usage = " +Usage: $prog + +"; +getopts('u:m:d:') or die $usage; + +my @old = glob("$opt_d/linetxt_*"); +unlink(@old) if @old; + +$/ = undef; +$_ = <>; +s/\s+$//gs; + +my $count = 1; +foreach (split(/\n/, $_)) +{ + s/^\s+//; + s/\s+$//; + s/\$URL/$opt_u/g; + s/\$MODEL/$opt_m/g; + $_ = ' ' unless $_; + my $big = s/^\$BIG:\s*//; + my $filename = sprintf('%s/linetxt_%02d.%s', $opt_d, $count++, + $big ? 'TXT' : 'txt'); +# print "$filename: ($_)\n"; next; + open(OUT, ">$filename") || die "$0 can't write $filename: $!\n"; + print OUT "$_"; + close(OUT); +} diff --git a/scripts/bitmaps/originals/DeveloperBmp.txt b/scripts/bitmaps/originals/DeveloperBmp.txt index 312af3b78f..b1d4c04abc 100644 --- a/scripts/bitmaps/originals/DeveloperBmp.txt +++ b/scripts/bitmaps/originals/DeveloperBmp.txt @@ -1,20 +1,2 @@ -Chrome OS verification is currently turned OFF. -Please turn on verification, or press SPACE to begin recovery. - - - - - - - - - - - - - - - - -http://google.com/chromeos/unverified -$URL +Chrome OS verification is turned off. +Press space to begin recovery. diff --git a/scripts/bitmaps/originals/RecoveryBmp.txt b/scripts/bitmaps/originals/RecoveryBmp.txt index f20927e3a9..dbfcc57419 100644 --- a/scripts/bitmaps/originals/RecoveryBmp.txt +++ b/scripts/bitmaps/originals/RecoveryBmp.txt @@ -1,20 +1,3 @@ Please remove all USB and SD devices to begin recovery. - - - - - - - - - - - - - - - - - -http://google.com/chromeos/recovery -$URL +$BIG: $URL +Model: $MODEL diff --git a/scripts/bitmaps/originals/RecoveryMissingOSBmp.txt b/scripts/bitmaps/originals/RecoveryMissingOSBmp.txt index 860c2e09cf..8a9447926b 100644 --- a/scripts/bitmaps/originals/RecoveryMissingOSBmp.txt +++ b/scripts/bitmaps/originals/RecoveryMissingOSBmp.txt @@ -1,20 +1,4 @@ -Chrome OS is missing or damaged. Please connect a recovery device. - - - - - - - - - - - - - - - - - -http://google.com/chromeos/recovery -$URL +Chrome OS is missing or damaged. +Please connect a recovery device. +$BIG: $URL +Model: $MODEL diff --git a/scripts/bitmaps/originals/RecoveryNoOSBmp.txt b/scripts/bitmaps/originals/RecoveryNoOSBmp.txt index e6c57f6980..b95e31ffae 100644 --- a/scripts/bitmaps/originals/RecoveryNoOSBmp.txt +++ b/scripts/bitmaps/originals/RecoveryNoOSBmp.txt @@ -1,20 +1,3 @@ The device you inserted does not contain Chrome OS. Try another? - - - - - - - - - - - - - - - - - -http://google.com/chromeos/recovery -$URL +$BIG: $URL +Model: $MODEL