mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-06-07 13:35:00 +00:00
[core] fix patch alpha on alpna image
This commit is contained in:
parent
96562bcc48
commit
01ffc4493c
@ -325,7 +325,7 @@ static void switch_img_patch_rgb_noalpha(switch_image_t *IMG, switch_image_t *im
|
|||||||
int max_w = MIN(img->d_w, IMG->d_w - abs(x));
|
int max_w = MIN(img->d_w, IMG->d_w - abs(x));
|
||||||
int max_h = MIN(img->d_h, IMG->d_h - abs(y));
|
int max_h = MIN(img->d_h, IMG->d_h - abs(y));
|
||||||
int j;
|
int j;
|
||||||
uint8_t alpha, alphadiff;
|
uint8_t alpha;
|
||||||
switch_rgb_color_t *rgb, *RGB;
|
switch_rgb_color_t *rgb, *RGB;
|
||||||
|
|
||||||
for (i = 0; i < max_h; i++) {
|
for (i = 0; i < max_h; i++) {
|
||||||
@ -335,18 +335,26 @@ static void switch_img_patch_rgb_noalpha(switch_image_t *IMG, switch_image_t *im
|
|||||||
|
|
||||||
alpha = rgb->a;
|
alpha = rgb->a;
|
||||||
|
|
||||||
if (RGB->a != 0) {
|
if (RGB->a == 0) {
|
||||||
|
*RGB = *rgb;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alpha == 255) {
|
if (alpha == 255) {
|
||||||
*RGB = *rgb;
|
*RGB = *rgb;
|
||||||
} else if (alpha != 0) {
|
continue;
|
||||||
alphadiff = 255 - alpha;
|
}
|
||||||
RGB->a = 255;
|
|
||||||
RGB->r = ((RGB->r * alphadiff) + (rgb->r * alpha)) >> 8;
|
if (alpha > 0) {
|
||||||
RGB->g = ((RGB->g * alphadiff) + (rgb->g * alpha)) >> 8;
|
uint8_t delta1, delta2, delta;
|
||||||
RGB->b = ((RGB->b * alphadiff) + (rgb->b * alpha)) >> 8;
|
|
||||||
|
delta1 = 255 - RGB->a;
|
||||||
|
delta2 = 255 - rgb->a;
|
||||||
|
delta = (delta1 * delta2) >> 8;
|
||||||
|
RGB->r = ((RGB->r * RGB->a) + (rgb->r * rgb->a)) / (RGB->a + rgb->a);
|
||||||
|
RGB->g = ((RGB->g * RGB->a) + (rgb->g * rgb->a)) / (RGB->a + rgb->a);
|
||||||
|
RGB->b = ((RGB->b * RGB->a) + (rgb->b * rgb->a)) / (RGB->a + rgb->a);
|
||||||
|
RGB->a = 255 - delta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -394,7 +402,7 @@ SWITCH_DECLARE(void) switch_img_patch_rgb(switch_image_t *IMG, switch_image_t *i
|
|||||||
int height = MIN(img->d_h, IMG->d_h - abs(y));
|
int height = MIN(img->d_h, IMG->d_h - abs(y));
|
||||||
void (*ARGBBlendRow)(const uint8_t* src_argb, const uint8_t* src_argb1, uint8_t* dst_argb, int width) = GetARGBBlend();
|
void (*ARGBBlendRow)(const uint8_t* src_argb, const uint8_t* src_argb1, uint8_t* dst_argb, int width) = GetARGBBlend();
|
||||||
|
|
||||||
switch_img_attenuate(img);
|
// switch_img_attenuate(img);
|
||||||
|
|
||||||
// Coalesce rows. we have same size images, treat as a single row
|
// Coalesce rows. we have same size images, treat as a single row
|
||||||
if (src_stride_argb0 == width * 4 &&
|
if (src_stride_argb0 == width * 4 &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user