1 /*
2 * Copyright (C) 2023 Rockchip Electronics Co., Ltd.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <stdio.h>
18 #include <stdlib.h>
19
main(int argc,char * argv)20 int main(int argc, char *argv)
21 {
22 unsigned n;
23 unsigned char *x;
24 unsigned m;
25 unsigned run_val;
26 unsigned run_count;
27
28 n = gimp_image.width * gimp_image.height;
29 m = 0;
30 x = gimp_image.pixel_data;
31
32 printf("struct {\n");
33 printf(" unsigned width;\n");
34 printf(" unsigned height;\n");
35 printf(" unsigned cwidth;\n");
36 printf(" unsigned cheight;\n");
37 printf(" unsigned char rundata[];\n");
38 printf("} font = {\n");
39 printf(" .width = %d,\n .height = %d,\n .cwidth = %d,\n .cheight = %d,\n", gimp_image.width, gimp_image.height,
40 gimp_image.width / 96, gimp_image.height);
41 printf(" .rundata = {\n");
42
43 run_val = (*x ? 0 : 255);
44 run_count = 1;
45 n--;
46 x += 3;
47
48 while (n-- > 0) {
49 unsigned val = (*x ? 0 : 255);
50 x += 3;
51 if ((val == run_val) && (run_count < 127)) {
52 run_count++;
53 } else {
54 eject:
55 printf("0x%02x,", run_count | (run_val ? 0x80 : 0x00));
56 run_val = val;
57 run_count = 1;
58 m += 5;
59 if (m >= 75) {
60 printf("\n");
61 m = 0;
62 }
63 }
64 }
65 printf("0x%02x,", run_count | (run_val ? 0x80 : 0x00));
66 printf("\n0x00,");
67 printf("\n");
68 printf(" }\n};\n");
69 return 0;
70 }
71