mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-13 13:16:52 +03:00
Update src/_imagingft.c
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
This commit is contained in:
parent
9c60e856ad
commit
78f78d2aa7
|
@ -1065,21 +1065,21 @@ font_render(FontObject *self, PyObject *args) {
|
||||||
if (src_alpha > 0) {
|
if (src_alpha > 0) {
|
||||||
/* unpremultiply BGRa */
|
/* unpremultiply BGRa */
|
||||||
int src_red = CLIP8((255 * (int)source[k * 4 + 2]) / src_alpha);
|
int src_red = CLIP8((255 * (int)source[k * 4 + 2]) / src_alpha);
|
||||||
int src_grn = CLIP8((255 * (int)source[k * 4 + 1]) / src_alpha);
|
int src_green = CLIP8((255 * (int)source[k * 4 + 1]) / src_alpha);
|
||||||
int src_blu = CLIP8((255 * (int)source[k * 4 + 0]) / src_alpha);
|
int src_blue = CLIP8((255 * (int)source[k * 4 + 0]) / src_alpha);
|
||||||
|
|
||||||
/* blend required if target has data */
|
/* blend required if target has data */
|
||||||
if (target[k * 4 + 3] > 0) {
|
if (target[k * 4 + 3] > 0) {
|
||||||
/* blend RGBA colors */
|
/* blend RGBA colors */
|
||||||
target[k * 4 + 0] = BLEND(src_alpha, target[k * 4 + 0], src_red, tmp);
|
target[k * 4 + 0] = BLEND(src_alpha, target[k * 4 + 0], src_red, tmp);
|
||||||
target[k * 4 + 1] = BLEND(src_alpha, target[k * 4 + 1], src_grn, tmp);
|
target[k * 4 + 1] = BLEND(src_alpha, target[k * 4 + 1], src_green, tmp);
|
||||||
target[k * 4 + 2] = BLEND(src_alpha, target[k * 4 + 2], src_blu, tmp);
|
target[k * 4 + 2] = BLEND(src_alpha, target[k * 4 + 2], src_blue, tmp);
|
||||||
target[k * 4 + 3] = CLIP8(src_alpha + MULDIV255(target[k * 4 + 3], (255 - src_alpha), tmp));
|
target[k * 4 + 3] = CLIP8(src_alpha + MULDIV255(target[k * 4 + 3], (255 - src_alpha), tmp));
|
||||||
} else {
|
} else {
|
||||||
/* paste unpremultiplied RGBA values */
|
/* paste unpremultiplied RGBA values */
|
||||||
target[k * 4 + 0] = src_red;
|
target[k * 4 + 0] = src_red;
|
||||||
target[k * 4 + 1] = src_grn;
|
target[k * 4 + 1] = src_green;
|
||||||
target[k * 4 + 2] = src_blu;
|
target[k * 4 + 2] = src_blue;
|
||||||
target[k * 4 + 3] = src_alpha;
|
target[k * 4 + 3] = src_alpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user