218
|
1
|
254
|
2 #include "subreader.h"
|
218
|
3 #include "sub.h"
|
202
|
4
|
213
|
5 //static int vo_font_loaded=-1;
|
|
6 font_desc_t* vo_font=NULL;
|
202
|
7
|
213
|
8 unsigned char* vo_osd_text="00:00:00";
|
|
9
|
218
|
10 void vo_draw_text_osd(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
|
213
|
11 int len=strlen(vo_osd_text);
|
|
12 int j;
|
|
13 int y=10;
|
|
14 int x=20;
|
202
|
15
|
213
|
16 for(j=0;j<len;j++){
|
|
17 int c=vo_osd_text[j];
|
|
18 int font=vo_font->font[c];
|
|
19 if(font>=0)
|
|
20 draw_alpha(x,y,
|
|
21 vo_font->width[c],
|
|
22 vo_font->pic_a[font]->h,
|
|
23 vo_font->pic_b[font]->bmp+vo_font->start[c],
|
|
24 vo_font->pic_a[font]->bmp+vo_font->start[c],
|
|
25 vo_font->pic_a[font]->w);
|
|
26 x+=vo_font->width[c]+vo_font->charspace;
|
|
27 }
|
218
|
28
|
|
29 }
|
|
30
|
|
31 int vo_osd_progbar_type=-1;
|
|
32 int vo_osd_progbar_value=100; // 0..255
|
|
33
|
|
34 void vo_draw_text_progbar(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
|
|
35 int len=strlen(vo_osd_text);
|
|
36 int i;
|
|
37 int y=dys/2;
|
|
38 int x;
|
|
39 int c,font;
|
|
40 int width=(dxs/2-vo_font->width[0x10]-vo_font->width[0x12]);
|
|
41 int elems=width/vo_font->width[0x11];
|
|
42 int mark=(vo_osd_progbar_value*(elems+1))>>8;
|
|
43 x=(dxs-width)/2;
|
|
44 // printf("osd.progbar width=%d xpos=%d\n",width,x);
|
|
45
|
|
46 c=vo_osd_progbar_type;font=vo_font->font[c];
|
|
47 if(vo_osd_progbar_type>0 && font>=0)
|
|
48 draw_alpha(x-vo_font->width[c]-vo_font->spacewidth,y,
|
|
49 vo_font->width[c],
|
|
50 vo_font->pic_a[font]->h,
|
|
51 vo_font->pic_b[font]->bmp+vo_font->start[c],
|
|
52 vo_font->pic_a[font]->bmp+vo_font->start[c],
|
|
53 vo_font->pic_a[font]->w);
|
213
|
54
|
218
|
55 c=OSD_PB_START;font=vo_font->font[c];
|
|
56 if(font>=0)
|
|
57 draw_alpha(x,y,
|
|
58 vo_font->width[c],
|
|
59 vo_font->pic_a[font]->h,
|
|
60 vo_font->pic_b[font]->bmp+vo_font->start[c],
|
|
61 vo_font->pic_a[font]->bmp+vo_font->start[c],
|
|
62 vo_font->pic_a[font]->w);
|
|
63 x+=vo_font->width[c];
|
|
64
|
|
65 for(i=0;i<elems;i++){
|
|
66 c=(i<mark)?OSD_PB_0:OSD_PB_1;font=vo_font->font[c];
|
|
67 if(font>=0)
|
|
68 draw_alpha(x,y,
|
|
69 vo_font->width[c],
|
|
70 vo_font->pic_a[font]->h,
|
|
71 vo_font->pic_b[font]->bmp+vo_font->start[c],
|
|
72 vo_font->pic_a[font]->bmp+vo_font->start[c],
|
|
73 vo_font->pic_a[font]->w);
|
|
74 x+=vo_font->width[c];
|
|
75 }
|
202
|
76
|
218
|
77 c=OSD_PB_END;font=vo_font->font[c];
|
|
78 if(font>=0)
|
|
79 draw_alpha(x,y,
|
|
80 vo_font->width[c],
|
|
81 vo_font->pic_a[font]->h,
|
|
82 vo_font->pic_b[font]->bmp+vo_font->start[c],
|
|
83 vo_font->pic_a[font]->bmp+vo_font->start[c],
|
|
84 vo_font->pic_a[font]->w);
|
|
85 // x+=vo_font->width[c];
|
|
86
|
|
87
|
|
88 // vo_osd_progbar_value=(vo_osd_progbar_value+1)&0xFF;
|
|
89
|
|
90 }
|
|
91
|
|
92
|
254
|
93 subtitle* vo_sub=NULL;
|
218
|
94
|
|
95 void vo_draw_text_sub(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
|
|
96 int i;
|
|
97 int y;
|
|
98
|
254
|
99 y=dys-(1+vo_sub->lines)*vo_font->height;
|
202
|
100
|
254
|
101 for(i=0;i<vo_sub->lines;i++){
|
|
102 unsigned char* text=vo_sub->text[i];// "Hello World! HÛDEJÓ!";
|
213
|
103 int len=strlen(text);
|
|
104 int j;
|
|
105 int xsize=-vo_font->charspace;
|
|
106 int x=0;
|
|
107
|
|
108 for(j=0;j<len;j++){
|
|
109 int w=vo_font->width[text[j]];
|
|
110 if(w>100) printf("gazvan: %d (%d=%c)\n",w,text[j],text[j]);
|
|
111 xsize+=w+vo_font->charspace;
|
|
112 }
|
|
113 //printf("text width = %d\n",xsize);
|
|
114
|
|
115 if(xsize>dxs) printf("Warning! SUB too wide!!! (%d>%d)\n",xsize,dxs);
|
|
116
|
|
117 x=dxs/2-xsize/2;
|
|
118
|
|
119 for(j=0;j<len;j++){
|
|
120 int c=text[j];
|
|
121 int font=vo_font->font[c];
|
|
122 if(x>=0 && x+vo_font->width[c]<dxs)
|
|
123 if(font>=0)
|
|
124 draw_alpha(x,y,
|
|
125 vo_font->width[c],
|
|
126 vo_font->pic_a[font]->h,
|
|
127 vo_font->pic_b[font]->bmp+vo_font->start[c],
|
|
128 vo_font->pic_a[font]->bmp+vo_font->start[c],
|
|
129 vo_font->pic_a[font]->w);
|
|
130 x+=vo_font->width[c]+vo_font->charspace;
|
|
131 }
|
|
132
|
|
133 y+=vo_font->height;
|
202
|
134 }
|
|
135
|
218
|
136 }
|
|
137
|
|
138
|
|
139 void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
|
|
140
|
|
141 if(!vo_font) return; // no font
|
|
142
|
|
143 if(vo_osd_text){
|
|
144 vo_draw_text_osd(dxs,dys,draw_alpha);
|
|
145 }
|
|
146
|
254
|
147 if(vo_sub){
|
218
|
148 vo_draw_text_sub(dxs,dys,draw_alpha);
|
|
149 }
|
|
150
|
|
151 if(vo_osd_progbar_type>=0){
|
|
152 vo_draw_text_progbar(dxs,dys,draw_alpha);
|
|
153 }
|
213
|
154
|
202
|
155 }
|
|
156
|