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