Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
5e7a8ea7
提交
5e7a8ea7
authored
5月 01, 2015
作者:
Anthony Minessale
提交者:
Michael Jerris
5月 28, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-7515: txt len
上级
669d9710
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
51 行增加
和
22 行删除
+51
-22
switch_core_video.h
src/include/switch_core_video.h
+4
-4
mod_cv.cpp
src/mod/applications/mod_cv/mod_cv.cpp
+11
-4
switch_core_video.c
src/switch_core_video.c
+36
-14
没有找到文件。
src/include/switch_core_video.h
浏览文件 @
5e7a8ea7
...
...
@@ -325,10 +325,10 @@ SWITCH_DECLARE(void) switch_img_txt_handle_destroy(switch_img_txt_handle_t **han
* \param[in] angle Angle to rotate
*/
SWITCH_DECLARE
(
switch_status
_t
)
switch_img_txt_handle_render
(
switch_img_txt_handle_t
*
handle
,
switch_image_t
*
img
,
int
x
,
int
y
,
const
char
*
text
,
const
char
*
font_family
,
const
char
*
font_color
,
const
char
*
bgcolor
,
uint16_t
font_size
,
double
angle
);
SWITCH_DECLARE
(
uint32
_t
)
switch_img_txt_handle_render
(
switch_img_txt_handle_t
*
handle
,
switch_image_t
*
img
,
int
x
,
int
y
,
const
char
*
text
,
const
char
*
font_family
,
const
char
*
font_color
,
const
char
*
bgcolor
,
uint16_t
font_size
,
double
angle
);
SWITCH_DECLARE
(
void
)
switch_img_patch_hole
(
switch_image_t
*
IMG
,
switch_image_t
*
img
,
int
x
,
int
y
,
switch_image_rect_t
*
rect
);
...
...
src/mod/applications/mod_cv/mod_cv.cpp
浏览文件 @
5e7a8ea7
...
...
@@ -198,18 +198,25 @@ static void context_render_text(cv_context_t *context, struct overlay *overlay,
if
(
len
<
5
)
len
=
5
;
width
=
(
int
)
(
float
)(
font_size
*
.95
f
*
len
);
//
width = (int) (float)(font_size * .95f * len);
switch_color_set_rgb
(
&
bgcolor
,
overlay
->
bg
);
switch_img_txt_handle_destroy
(
&
overlay
->
txthandle
);
switch_img_txt_handle_create
(
&
overlay
->
txthandle
,
overlay
->
font_face
,
overlay
->
fg
,
overlay
->
bg
,
font_size
,
0
,
NULL
);
width
=
switch_img_txt_handle_render
(
overlay
->
txthandle
,
NULL
,
font_size
/
2
,
font_size
/
2
,
text
,
NULL
,
overlay
->
fg
,
overlay
->
bg
,
0
,
0
);
if
(
!
overlay
->
png
||
(
overlay
->
png
->
d_w
!=
width
||
overlay
->
png
->
d_h
!=
font_size
*
2
))
{
switch_img_free
(
&
overlay
->
png
);
overlay
->
png
=
switch_img_alloc
(
NULL
,
SWITCH_IMG_FMT_I420
,
width
,
font_size
*
2
,
1
);
}
switch_img_txt_handle_destroy
(
&
overlay
->
txthandle
);
switch_img_txt_handle_create
(
&
overlay
->
txthandle
,
overlay
->
font_face
,
overlay
->
fg
,
overlay
->
bg
,
font_size
,
0
,
NULL
);
switch_img_fill
(
overlay
->
png
,
0
,
0
,
overlay
->
png
->
d_w
,
overlay
->
png
->
d_h
,
&
bgcolor
);
switch_img_txt_handle_render
(
overlay
->
txthandle
,
...
...
src/switch_core_video.c
浏览文件 @
5e7a8ea7
...
...
@@ -681,9 +681,10 @@ static void draw_bitmap(switch_img_txt_handle_t *handle, switch_image_t *img, FT
#endif
SWITCH_DECLARE
(
switch_status
_t
)
switch_img_txt_handle_render
(
switch_img_txt_handle_t
*
handle
,
switch_image_t
*
img
,
SWITCH_DECLARE
(
uint32
_t
)
switch_img_txt_handle_render
(
switch_img_txt_handle_t
*
handle
,
switch_image_t
*
img
,
int
x
,
int
y
,
const
char
*
text
,
const
char
*
font_family
,
const
char
*
font_color
,
const
char
*
bgcolor
,
uint16_t
font_size
,
double
angle
)
const
char
*
font_family
,
const
char
*
font_color
,
const
char
*
bgcolor
,
uint16_t
font_size
,
double
angle
)
{
#if SWITCH_HAVE_FREETYPE
FT_GlyphSlot
slot
;
...
...
@@ -694,9 +695,12 @@ SWITCH_DECLARE(switch_status_t) switch_img_txt_handle_render(switch_img_txt_hand
int
index
=
0
;
FT_ULong
ch
;
FT_Face
face
;
uint32_t
width
=
0
;
int
this_x
=
0
,
last_x
=
0
,
space
=
0
;
if
(
zstr
(
text
))
return
SWITCH_STATUS_FALSE
;
switch_assert
(
img
->
fmt
==
SWITCH_IMG_FMT_I420
);
if
(
zstr
(
text
))
return
0
;
switch_assert
(
!
img
||
img
->
fmt
==
SWITCH_IMG_FMT_I420
);
if
(
font_family
)
{
handle
->
font_family
=
switch_core_strdup
(
handle
->
pool
,
font_family
);
...
...
@@ -730,12 +734,12 @@ SWITCH_DECLARE(switch_status_t) switch_img_txt_handle_render(switch_img_txt_hand
error
=
FT_New_Face
(
handle
->
library
,
font_family
,
0
,
&
face
);
/* create face object */
if
(
error
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Unable to open font %s
\n
"
,
font_family
);
return
SWITCH_STATUS_FALSE
;
return
0
;
}
/* use 50pt at 100dpi */
error
=
FT_Set_Char_Size
(
face
,
64
*
font_size
,
0
,
96
,
96
);
/* set character size */
if
(
error
)
return
SWITCH_STATUS_FALSE
;
if
(
error
)
return
0
;
slot
=
face
->
glyph
;
...
...
@@ -766,10 +770,25 @@ SWITCH_DECLARE(switch_status_t) switch_img_txt_handle_render(switch_img_txt_hand
/* load glyph image into the slot (erase previous one) */
error
=
FT_Load_Char
(
face
,
ch
,
FT_LOAD_RENDER
);
if
(
error
)
continue
;
/* now, draw to our target surface (convert position) */
draw_bitmap
(
handle
,
img
,
&
slot
->
bitmap
,
pen
.
x
+
slot
->
bitmap_left
,
pen
.
y
-
slot
->
bitmap_top
+
font_size
);
this_x
=
pen
.
x
+
slot
->
bitmap_left
;
if
(
img
)
{
/* now, draw to our target surface (convert position) */
draw_bitmap
(
handle
,
img
,
&
slot
->
bitmap
,
this_x
,
pen
.
y
-
slot
->
bitmap_top
+
font_size
);
}
if
(
last_x
)
{
space
=
this_x
-
last_x
;
}
else
{
space
=
0
;
}
last_x
=
this_x
;
width
+=
space
;
/* increment pen position */
pen
.
x
+=
slot
->
advance
.
x
>>
6
;
...
...
@@ -778,9 +797,9 @@ SWITCH_DECLARE(switch_status_t) switch_img_txt_handle_render(switch_img_txt_hand
FT_Done_Face
(
face
);
return
SWITCH_STATUS_SUCCESS
;
return
width
+
slot
->
bitmap
.
width
*
3
;
#else
return
SWITCH_STATUS_FALSE
;
return
0
;
#endif
}
...
...
@@ -836,13 +855,16 @@ SWITCH_DECLARE(switch_image_t *) switch_img_write_text_img(int w, int h, const c
if
(
len
<
5
)
len
=
5
;
width
=
(
int
)
(
float
)(
font_size
*
0
.
75
f
*
len
);
txtimg
=
switch_img_alloc
(
NULL
,
SWITCH_IMG_FMT_I420
,
width
,
font_size
*
2
,
1
);
switch_img_txt_handle_create
(
&
txthandle
,
font_face
,
fg
,
bg
,
font_size
,
0
,
NULL
);
switch_color_set_rgb
(
&
bgcolor
,
bg
);
width
=
switch_img_txt_handle_render
(
txthandle
,
NULL
,
font_size
/
2
,
font_size
/
2
,
txt
,
NULL
,
fg
,
bg
,
0
,
0
);
txtimg
=
switch_img_alloc
(
NULL
,
SWITCH_IMG_FMT_I420
,
width
,
font_size
*
2
,
1
);
switch_img_fill
(
txtimg
,
0
,
0
,
txtimg
->
d_w
,
txtimg
->
d_h
,
&
bgcolor
);
switch_img_txt_handle_render
(
txthandle
,
txtimg
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论