FreeCalypso > hg > tcs211-l1-reconst
comparison chipsetsw/drivers/drv_app/r2d/lcds/E_Sample/custom_process.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 # Mode os scanning (vertical or horizontal) | |
4 $mode=$ARGV[0]; | |
5 | |
6 # Name of file used to transfer data between this script and the r2d_font_tool | |
7 $data=$ARGV[1]; | |
8 | |
9 if (($#ARGV+1)>2) | |
10 { | |
11 $x=$ARGV[3]; | |
12 open(DATA,">$data") or die "Cannot create data file : $!\n"; | |
13 $words = int($x/2)+1; | |
14 | |
15 # One word must be added because the alignement is done by excess | |
16 print DATA $words; | |
17 close(DATA); | |
18 | |
19 | |
20 } | |
21 else | |
22 { | |
23 # Open the data file to import glyph bit matrix generated by r2d_font_tool | |
24 open(DATA,"$data") or die "Cannot open input file : $!\n"; | |
25 | |
26 # It is the size unmodified by r2d_font_tool (width in vertical mode and | |
27 # height in horizontal mode). It corresponds to the width/height for the | |
28 # current glyph | |
29 $matrix_size=int(<DATA>); | |
30 | |
31 # It is the size which is word aligned by r2d_font_tool (height in | |
32 # vertical mode and width in horizontal one) | |
33 # It corresponds to the max width/height on all fonts. | |
34 $matrix_aligned_size=int(<DATA>); | |
35 | |
36 # Original value before word alignment | |
37 # (Max value on all glyphs before alignment) | |
38 $matrix_max_size=int(<DATA>); | |
39 | |
40 # Width of the glyph image in the bitmap | |
41 $matrix_image_width=int(<DATA>); | |
42 | |
43 # Height of the glyph in the bitmap | |
44 $matrix_image_height=int(<DATA>); | |
45 | |
46 if ($mode =~ /vertical/) | |
47 { | |
48 # Scanning of the glyph bit matrix done column per column | |
49 # (since datas are saved column per column by r2d_font_tool | |
50 # when in horizontal mode) | |
51 for($i=0;$i<$matrix_size;$i++) | |
52 { | |
53 for($j=0;$j<$matrix_aligned_size;$j++) | |
54 { | |
55 $matrix{$i.".".$j}=int(<DATA>); | |
56 } | |
57 } | |
58 } | |
59 else | |
60 { | |
61 # Scanning of the glyph bit matrix done line per line | |
62 for($i=0;$i<$matrix_aligned_size;$i++) | |
63 { | |
64 for($j=0;$j<$matrix_size;$j++) | |
65 { | |
66 $matrix{$i.".".$j}=int(<DATA>); | |
67 } | |
68 } | |
69 } | |
70 close(DATA); | |
71 | |
72 | |
73 # That part of the code is translating the glyph (initially represented | |
74 # as a bit matrix) to a format which is compatible with the current LCD. | |
75 # | |
76 # In this example, the LCD is a 24 bpp one. So, a bit 0 (correponding to black) | |
77 # must be converted to 0, and 1 (for white) to 0xFFFFFF. | |
78 # | |
79 # The scanning must use the IMAGE width in vertical mode | |
80 # and the IMAGE height in horizontal mode. | |
81 | |
82 # In vertical mode, the height must use max_size on all glyph | |
83 # In horizontal mode, the width must use the max_size. | |
84 # You can either use the aligned_version if you LCD is a 1bpp one and | |
85 # or you can use the non aligned one (matrix_max_size) and do the alignment | |
86 # yourself. | |
87 | |
88 # In our case, the LCD is a 24bpp, so no alignment is required and the | |
89 # max_size is used directly. | |
90 | |
91 $words=int(($matrix_max_size/2)) +1; | |
92 $aligned=$words*2; | |
93 | |
94 open(DATA,">$data") or die "Cannot create data file : $!\n"; | |
95 if ($mode =~ /vertical/) | |
96 { | |
97 # Scanning column per column | |
98 for($i=0;$i<$matrix_image_width;$i++) | |
99 { | |
100 for($j=0;$j<$matrix_max_size;$j++) | |
101 { | |
102 $r=$matrix{$i.".".$j}; | |
103 # Convertion of bit to color value | |
104 if ($r == 0) | |
105 { | |
106 print DATA "0\n"; | |
107 } | |
108 else | |
109 { | |
110 print DATA "0x00FFFFFF\n"; | |
111 } | |
112 } | |
113 } | |
114 } | |
115 else | |
116 { | |
117 $k=0; | |
118 # Scanning line per line | |
119 for($j=0;$j<$matrix_image_height;$j++) | |
120 { | |
121 for($i=0;$i<$aligned/2;$i++) | |
122 { | |
123 | |
124 $k=2*$i; | |
125 $ra=$matrix{$k.".".$j}; | |
126 | |
127 | |
128 # Conversion of bit to color value | |
129 if ($ra != 0) | |
130 { | |
131 $ra=0x0FFFF; | |
132 } | |
133 else | |
134 { | |
135 $ra=0; | |
136 } | |
137 | |
138 | |
139 | |
140 | |
141 $k++; | |
142 $rb=$matrix{$k.".".$j}; | |
143 | |
144 | |
145 # Conversion of bit to color value | |
146 if ($rb != 0) | |
147 { | |
148 $rb=0x0FFFF0000; | |
149 } | |
150 else | |
151 { | |
152 $rb=0; | |
153 } | |
154 | |
155 | |
156 $rb=$rb | $ra; | |
157 | |
158 | |
159 $res=sprintf "0x%08X\n",$rb; | |
160 | |
161 print DATA $res; | |
162 } | |
163 } | |
164 } | |
165 close(DATA); | |
166 } |