mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 08:23:29 +00:00
Merge pull request #39200 from azagaya/fix-blend-2
Fixing wrong blending rect methods
This commit is contained in:
commit
ec1bf96e41
1 changed files with 10 additions and 12 deletions
|
@ -2539,15 +2539,14 @@ void Image::blend_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const P
|
||||||
int dst_y = dest_rect.position.y + i;
|
int dst_y = dest_rect.position.y + i;
|
||||||
|
|
||||||
Color sc = img->get_pixel(src_x, src_y);
|
Color sc = img->get_pixel(src_x, src_y);
|
||||||
|
if (sc.a != 0) {
|
||||||
Color dc = get_pixel(dst_x, dst_y);
|
Color dc = get_pixel(dst_x, dst_y);
|
||||||
dc.r = (double)(sc.a * sc.r + dc.a * (1.0 - sc.a) * dc.r);
|
dc = dc.blend(sc);
|
||||||
dc.g = (double)(sc.a * sc.g + dc.a * (1.0 - sc.a) * dc.g);
|
|
||||||
dc.b = (double)(sc.a * sc.b + dc.a * (1.0 - sc.a) * dc.b);
|
|
||||||
dc.a = (double)(sc.a + dc.a * (1.0 - sc.a));
|
|
||||||
set_pixel(dst_x, dst_y, dc);
|
set_pixel(dst_x, dst_y, dc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest) {
|
void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest) {
|
||||||
ERR_FAIL_COND_MSG(p_src.is_null(), "It's not a reference to a valid Image object.");
|
ERR_FAIL_COND_MSG(p_src.is_null(), "It's not a reference to a valid Image object.");
|
||||||
|
@ -2594,16 +2593,15 @@ void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, c
|
||||||
int dst_y = dest_rect.position.y + i;
|
int dst_y = dest_rect.position.y + i;
|
||||||
|
|
||||||
Color sc = img->get_pixel(src_x, src_y);
|
Color sc = img->get_pixel(src_x, src_y);
|
||||||
|
if (sc.a != 0) {
|
||||||
Color dc = get_pixel(dst_x, dst_y);
|
Color dc = get_pixel(dst_x, dst_y);
|
||||||
dc.r = (double)(sc.a * sc.r + dc.a * (1.0 - sc.a) * dc.r);
|
dc = dc.blend(sc);
|
||||||
dc.g = (double)(sc.a * sc.g + dc.a * (1.0 - sc.a) * dc.g);
|
|
||||||
dc.b = (double)(sc.a * sc.b + dc.a * (1.0 - sc.a) * dc.b);
|
|
||||||
dc.a = (double)(sc.a + dc.a * (1.0 - sc.a));
|
|
||||||
set_pixel(dst_x, dst_y, dc);
|
set_pixel(dst_x, dst_y, dc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Image::fill(const Color &c) {
|
void Image::fill(const Color &c) {
|
||||||
ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot fill in compressed or custom image formats.");
|
ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot fill in compressed or custom image formats.");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue