SWITCH_DECLARE(switch_image_t *) switch_img_copy_rect(switch_image_t *img, int x, int y, int w, int h);
-SWITCH_DECLARE(void) switch_image_draw_pixel(switch_image_t *img, int x, int y, switch_yuv_color_t color);
+SWITCH_DECLARE(void) switch_img_fill(switch_image_t *img, int x, int y, int w, int h, switch_yuv_color_t color);
+
+SWITCH_DECLARE(void) switch_img_draw_pixel(switch_image_t *img, int x, int y, switch_yuv_color_t color);
SWITCH_DECLARE(void) switch_color_set(switch_yuv_color_t *color, char *color_str);
if ( i < 0 || j < 0 || i >= img->d_w || j >= img->d_h) continue;
if (bitmap->buffer[q * bitmap->width + p] > 128) {
- switch_image_draw_pixel(img, i, j, color);
+ switch_img_draw_pixel(img, i, j, color);
}
}
}
static void reset_image(switch_image_t *img, switch_yuv_color_t *color)
{
- int i;
-
- for (i = 0; i < img->h; i++) {
- memset(img->planes[SWITCH_PLANE_Y] + img->stride[SWITCH_PLANE_Y] * i, color->y, img->d_w);
- }
-
- for (i = 0; i < img->h / 2; i++) {
- memset(img->planes[SWITCH_PLANE_U] + img->stride[SWITCH_PLANE_U] * i, color->u, img->d_w / 2);
- memset(img->planes[SWITCH_PLANE_V] + img->stride[SWITCH_PLANE_V] * i, color->v, img->d_w / 2);
- }
+ switch_img_fill(img, 0, 0, img->w, img->h, *color);
}
#define SCALE_FACTOR 360.0f
if (ret != 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Scaling Error: ret: %d\n", ret);
} else {
+ if (layer->img->d_h > 20) {
+ // reserv the bottom room for text, e.g. caller id
+ // switch_img_set_rect(layer->img, 0, 0, layer->img->d_w, layer->img->d_h - 20);
+ }
switch_img_patch(IMG, layer->img, x, y);
}
} else {
switch_img_draw_text(conference->canvas->img, 10, 80, color, 24, "AVA 123 你好 FreeSWITCH\nFreeSWITCH Rocks!");
switch_img_draw_text(conference->canvas->img, 10, 160, color, 36, "AVA 123 你好 FreeSWITCH\nFreeSWITCH Rocks!");
switch_img_draw_text(conference->canvas->img, 10, 300, color, 72, "AVA 123 你好 FreeSWITCH\nFreeSWITCH Rocks!");
+
+ switch_img_fill(conference->canvas->img, 300, 10, 400, 40, color);
+ switch_color_set(&color, "#FF0000");
+ switch_img_draw_text(conference->canvas->img, 300, 10, color, 32, "FreeSWITCH");
}
if (used) {
return new_img;
}
-SWITCH_DECLARE(void) switch_image_draw_pixel(switch_image_t *img, int x, int y, switch_yuv_color_t color)
+SWITCH_DECLARE(void) switch_img_draw_pixel(switch_image_t *img, int x, int y, switch_yuv_color_t color)
{
if (x < 0 || y < 0 || x >= img->d_w || y >= img->d_h) return;
}
}
+SWITCH_DECLARE(void) switch_img_fill(switch_image_t *img, int x, int y, int w, int h, switch_yuv_color_t color)
+{
+ int len, i;
+
+ if (x < 0 || y < 0 || x >= img->d_w || y >= img->d_h) return;
+
+ len = MIN(w, img->d_w - x);
+ if (len <= 0) return;
+
+ for (i = y; i < (y + h) && i < img->d_h; i++) {
+ memset(img->planes[SWITCH_PLANE_Y] + img->stride[SWITCH_PLANE_Y] * i + x, color.y, len);
+ }
+
+ len /= 2;
+
+ for (i = y; i < (y + h) && i < img->d_h; i += 2) {
+ memset(img->planes[SWITCH_PLANE_U] + img->stride[SWITCH_PLANE_U] * i / 2 + x / 2, color.u, len);
+ memset(img->planes[SWITCH_PLANE_V] + img->stride[SWITCH_PLANE_V] * i / 2 + x / 2, color.v, len);
+ }
+}
+
static uint8_t scv_art[14][16] = {
{0x00, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x00},
{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00},