FreeCalypso > hg > leo2moko-debug
comparison chipsetsw/drivers/drv_app/r2d/lcds/PC_DSAMPLE/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)+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) ; | |
92 $aligned=$words; | |
93 | |
94 open(DATA,">$data") or die "Cannot create data file : $!\n"; | |
95 | |
96 | |
97 # Scanning line per line | |
98 for($j=0;$j<$matrix_image_height;$j++) | |
99 { | |
100 for($i=0;$i<$aligned;$i++) | |
101 { | |
102 $ra=$matrix{$i.".".$j}; | |
103 | |
104 | |
105 # Conversion of bit to color value | |
106 if ($ra == 0) | |
107 { | |
108 $ra=0x00FFFFFF; | |
109 } | |
110 else | |
111 { | |
112 $ra=0x00000000; | |
113 } | |
114 | |
115 | |
116 | |
117 | |
118 $res=sprintf "0x%08X\n",$ra; | |
119 print DATA $res; | |
120 } | |
121 } | |
122 | |
123 close(DATA); | |
124 | |
125 } |