Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1702 | - | 1 | using System; |
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.IO; |
||
6 | using System.Drawing; |
||
7 | |||
8 | namespace OSD |
||
9 | { |
||
10 | class mcm |
||
11 | { |
||
12 | |||
13 | public static Bitmap[] readMCM(string file) |
||
14 | { |
||
15 | Bitmap[] imagearray = new Bitmap[256]; |
||
16 | |||
17 | if (!File.Exists(file)) |
||
18 | { |
||
19 | System.Windows.Forms.MessageBox.Show("Font file does not exist : " + file); |
||
20 | return imagearray; |
||
21 | } |
||
22 | |||
23 | for (int a = 0; a < imagearray.Length; a++) |
||
24 | { |
||
25 | imagearray[a] = new Bitmap(12, 18); |
||
26 | } |
||
27 | |||
28 | StreamReader sr = new StreamReader(file); |
||
29 | |||
30 | string device = sr.ReadLine(); |
||
31 | |||
32 | // 00 black 10 white x1 = trans/grey |
||
33 | |||
34 | int x = 0, y = 0; |
||
35 | |||
36 | int image = 0; |
||
37 | |||
38 | while (!sr.EndOfStream) |
||
39 | { |
||
40 | string line = ""; |
||
41 | y = 0; |
||
42 | while (y < 18) |
||
43 | { |
||
44 | x = 0; |
||
45 | while (x < 12) |
||
46 | { |
||
47 | if (x == 0 || x == 4 || x == 8) |
||
48 | { |
||
49 | //Console.WriteLine("line"); |
||
50 | line = sr.ReadLine(); |
||
51 | if (line == null) |
||
52 | return imagearray; |
||
53 | } |
||
54 | |||
55 | string i1 = line.Substring((x % 4) * 2, 2); |
||
56 | |||
57 | //Console.WriteLine(image + " " + line + " " + i1 + " " + x + " " + y); |
||
58 | |||
59 | if (i1 == "01" || i1 == "11") |
||
60 | { |
||
61 | imagearray[image].SetPixel(x, y, Color.Transparent); |
||
62 | } |
||
63 | else if (i1 == "00") |
||
64 | { |
||
65 | imagearray[image].SetPixel(x, y, Color.Black); |
||
66 | } |
||
67 | else if (i1 == "10") |
||
68 | { |
||
69 | imagearray[image].SetPixel(x, y, Color.White); |
||
70 | } |
||
71 | |||
72 | x++; |
||
73 | } |
||
74 | y++; |
||
75 | } |
||
76 | |||
77 | // left |
||
78 | int left = 256 - 216; |
||
79 | while ((left / 4) > 0) |
||
80 | { |
||
81 | sr.ReadLine(); // 1 |
||
82 | left -= 4; |
||
83 | } |
||
84 | |||
85 | image++; |
||
86 | } |
||
87 | |||
88 | return imagearray; |
||
89 | } |
||
90 | } |
||
91 | } |