comparison chipsetsw/drivers/drv_app/r2d/lcds/ColorBoard/Demo/tor2d.pl @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 #!perl
2
3 $in=$ARGV[0];
4 $out=$ARGV[1];
5
6 $nin = $in;
7
8 $nin =~ s/\..*$/.txt/;
9
10 #print "->$nin";
11
12 print "convert -modulate 160 -colors 256 -dither $in TEXT:$nin\n";
13 system("convert -modulate 160 -colors 256 -dither $in TEXT:$nin");
14
15 $maxx=0;
16 $maxy=0;
17 open(IN,$nin) or die "Cannot read input file:$! \n";
18 while($line=<IN>)
19 {
20 if ($line =~ /^([0-9]+),([0-9]+):[\s\t]*([0-9]+),([0-9]+),([0-9]+)[\s\t]*.*$/)
21 {
22 $x=int($1);
23 $y=int($2);
24 $r=int($3);
25 $g=int($4);
26 $b=int($5);
27 if ($x>$maxx)
28 {
29 $maxx=$x;
30 }
31
32 if ($y>$maxy)
33 {
34 $maxy=$y;
35 }
36
37 $b=$b >> 14;
38 $g=$g >> 13;
39 $r=$r >> 13;
40
41 $value = ($r << 5) | ($g << 2) | $b;
42
43 $data{$x.":".$y}=$value;
44
45
46 }
47 }
48 close(IN);
49
50 $maxx=$maxx+1;
51 $maxy=$maxy+1;
52
53 open(OUT,">$out.c") or die "Cannot create outputfile: $!\n";
54
55 $length=$maxy*(($maxx/2)+1);
56
57 print OUT "const UINT32 $out"."[]={\n";
58 print OUT "$maxx,$maxy,$length,\n";
59 for($j=0;$j<$maxy;$j++)
60 {
61 for($i=0;$i<($maxx/2)+1;$i++)
62 {
63 $x=2*$i;
64
65 if (exists $data{$x.":".$j})
66 {
67 $ra= (~$data{$x.":".$j}) & 0x0FF;
68 }
69 else
70 {
71 $ra=0x0000;
72 }
73 $x=$x+1;
74 if (exists $data{$x.":".$j})
75 {
76 $rb= (~$data{$x.":".$j}) & 0x0FF;
77 }
78 else
79 {
80 $rb=0x0000;
81 }
82
83
84 $value=($rb<<16) | $ra;
85 $result=sprintf "0x%08X",$value;
86 print OUT "$result,\n";
87 }
88 }
89 print OUT "0x0\n";
90 print OUT "};\n";
91 close(OUT);
92
93 #rename "$out.c","E:\\BT\\Drivers\\Common\\R2D\\$out.c"