*/
SWITCH_DECLARE(void) switch_color_set_yuv(switch_yuv_color_t *color, const char *color_str);
-/*!\brief Convert RGB color to YUV
-*
-* \param[in] rgb RGB color pointer
-* \param[out] yuv YUV color pointer
-*/
-SWITCH_DECLARE(void) switch_color_rgb2yuv(switch_rgb_color_t *rgb, switch_yuv_color_t *yuv);
-
-/*!\brief Convert YUV color to RGB
-*
-* \param[in] yuv YUV color pointer
-* \param[out] rgb RGB color pointer
-*/
-SWITCH_DECLARE(void) switch_color_yuv2rgb(switch_yuv_color_t *yuv, switch_rgb_color_t *rgb);
-
/*!\brief Created a text handle
*
* \param[out] handleP Pointer to the text handle pointer
SWITCH_DECLARE(switch_status_t) switch_png_open(switch_png_t **pngP, const char *file_name);
SWITCH_DECLARE(void) switch_png_free(switch_png_t **pngP);
-SWITCH_DECLARE(void) switch_img_get_yuv_pixel(switch_image_t *img, switch_yuv_color_t *yuv, int x, int y);
-
-SWITCH_DECLARE(void) switch_img_get_rgb_pixel(switch_image_t *img, switch_rgb_color_t *rgb, int x, int y);
-
/*!\brief put a small img over a big IMG at position x,y, with alpha transparency
*
* Both IMG and img must be non-NULL
#include <gd.h>
#endif
+static inline void switch_img_get_yuv_pixel(switch_image_t *img, switch_yuv_color_t *yuv, int x, int y);
+
+static inline void switch_img_get_rgb_pixel(switch_image_t *img, switch_rgb_color_t *rgb, int x, int y);
+
+
+/*!\brief Convert RGB color to YUV
+*
+* \param[in] rgb RGB color pointer
+* \param[out] yuv YUV color pointer
+*/
+static inline void switch_color_rgb2yuv(switch_rgb_color_t *rgb, switch_yuv_color_t *yuv);
+
+/*!\brief Convert YUV color to RGB
+*
+* \param[in] yuv YUV color pointer
+* \param[out] rgb RGB color pointer
+*/
+static inline void switch_color_yuv2rgb(switch_yuv_color_t *yuv, switch_rgb_color_t *rgb);
+
struct pos_el {
switch_img_position_t pos;
const char *name;
switch_img_get_rgb_pixel(IMG, &RGB, x + j, y + i);
rgb = (switch_rgb_color_t *)(img->planes[SWITCH_PLANE_PACKED] + i * img->stride[SWITCH_PLANE_PACKED] + j * 4);
- RGB.a = 255;
- RGB.r = ((RGB.r * (255 - alpha)) >> 8) + ((rgb->r * alpha) >> 8);
- RGB.g = ((RGB.g * (255 - alpha)) >> 8) + ((rgb->g * alpha) >> 8);
- RGB.b = ((RGB.b * (255 - alpha)) >> 8) + ((rgb->b * alpha) >> 8);
+ if (alpha < 255) {
+ RGB.a = 255;
+ RGB.r = ((RGB.r * (255 - alpha)) >> 8) + ((rgb->r * alpha) >> 8);
+ RGB.g = ((RGB.g * (255 - alpha)) >> 8) + ((rgb->g * alpha) >> 8);
+ RGB.b = ((RGB.b * (255 - alpha)) >> 8) + ((rgb->b * alpha) >> 8);
- switch_img_draw_pixel(IMG, x + j, y + i, &RGB);
+ switch_img_draw_pixel(IMG, x + j, y + i, &RGB);
+ } else {
+ switch_img_draw_pixel(IMG, x + j, y + i, rgb);
+ }
}
}
}
#endif
}
-SWITCH_DECLARE(void) switch_img_get_yuv_pixel(switch_image_t *img, switch_yuv_color_t *yuv, int x, int y)
+static inline void switch_img_get_yuv_pixel(switch_image_t *img, switch_yuv_color_t *yuv, int x, int y)
{
#ifdef SWITCH_HAVE_YUV
// switch_assert(img->fmt == SWITCH_IMG_FMT_I420);
#endif
}
-SWITCH_DECLARE(void) switch_img_get_rgb_pixel(switch_image_t *img, switch_rgb_color_t *rgb, int x, int y)
+static inline void switch_img_get_rgb_pixel(switch_image_t *img, switch_rgb_color_t *rgb, int x, int y)
{
#ifdef SWITCH_HAVE_YUV
if (x < 0 || y < 0 || x >= img->d_w || y >= img->d_h) return;
SWITCH_DECLARE(void) switch_img_overlay(switch_image_t *IMG, switch_image_t *img, int x, int y, uint8_t alpha)
{
int i, j, len, max_h;
- switch_rgb_color_t RGB, rgb, c;
+ switch_rgb_color_t RGB = {0}, rgb = {0}, c;
int xoff = 0, yoff = 0;
switch_assert(IMG->fmt == SWITCH_IMG_FMT_I420);
}
}
-SWITCH_DECLARE(void) switch_color_rgb2yuv(switch_rgb_color_t *rgb, switch_yuv_color_t *yuv)
+static inline void switch_color_rgb2yuv(switch_rgb_color_t *rgb, switch_yuv_color_t *yuv)
{
#ifdef SWITCH_HAVE_YUV
yuv->y = (uint8_t)(((rgb->r * 4897) >> 14) + ((rgb->g * 9611) >> 14) + ((rgb->b * 1876) >> 14));
#define CLAMP(val) MAX(0, MIN(val, 255))
-SWITCH_DECLARE(void) switch_color_yuv2rgb(switch_yuv_color_t *yuv, switch_rgb_color_t *rgb)
+static inline void switch_color_yuv2rgb(switch_yuv_color_t *yuv, switch_rgb_color_t *rgb)
{
#ifdef SWITCH_HAVE_YUV
#if 0
if (handle->use_bgcolor) {
switch_img_draw_pixel(img, i, j, &handle->gradient_table[gradient * MAX_GRADIENT / 256]);
} else {
- switch_rgb_color_t rgb_color;
+ switch_rgb_color_t rgb_color = {0};
switch_rgb_color_t c;
switch_img_get_rgb_pixel(img, &rgb_color, i, j);