@@ -553,16 +553,11 @@ static void blit_with_alpha(video::IImage *src, video::IImage *dst,
553
553
static void blit_with_alpha_overlay (video::IImage *src, video::IImage *dst,
554
554
v2s32 src_pos, v2s32 dst_pos, v2u32 size);
555
555
556
- // Like blit_with_alpha overlay, but uses an int to calculate the ratio
557
- // and modifies any destination pixels that are not fully transparent
558
- static void blit_with_interpolate_overlay (video::IImage *src, video::IImage *dst,
559
- v2s32 src_pos, v2s32 dst_pos, v2u32 size, int ratio);
560
-
561
556
// Apply a color to an image. Uses an int (0-255) to calculate the ratio.
562
557
// If the ratio is 255 or -1 and keep_alpha is true, then it multiples the
563
558
// color alpha with the destination alpha.
564
559
// Otherwise, any pixels that are not fully transparent get the color alpha.
565
- static void apply_colorize (video::IImage *dst, v2s32 dst_pos, v2u32 size,
560
+ static void apply_colorize (video::IImage *dst, v2u32 dst_pos, v2u32 size,
566
561
video::SColor color, int ratio, bool keep_alpha);
567
562
568
563
// Apply a mask to an image
@@ -1656,7 +1651,7 @@ bool TextureSource::generateImagePart(std::string part_of_name,
1656
1651
else if (ratio_str == " alpha" )
1657
1652
keep_alpha = true ;
1658
1653
1659
- apply_colorize (baseimg, v2s32 (0 , 0 ), baseimg->getDimension (), color, ratio, keep_alpha);
1654
+ apply_colorize (baseimg, v2u32 (0 , 0 ), baseimg->getDimension (), color, ratio, keep_alpha);
1660
1655
}
1661
1656
else if (str_starts_with (part_of_name, " [applyfiltersformesh" ))
1662
1657
{
@@ -1753,62 +1748,35 @@ static void blit_with_alpha_overlay(video::IImage *src, video::IImage *dst,
1753
1748
}
1754
1749
}
1755
1750
1756
- /*
1757
- Draw an image on top of an another one, using the specified ratio
1758
- modify all partially-opaque pixels in the destination.
1759
- */
1760
- static void blit_with_interpolate_overlay (video::IImage *src, video::IImage *dst,
1761
- v2s32 src_pos, v2s32 dst_pos, v2u32 size, int ratio)
1762
- {
1763
- for (u32 y0 = 0 ; y0 < size.Y ; y0 ++)
1764
- for (u32 x0 = 0 ; x0 < size.X ; x0++)
1765
- {
1766
- s32 src_x = src_pos.X + x0;
1767
- s32 src_y = src_pos.Y + y0 ;
1768
- s32 dst_x = dst_pos.X + x0;
1769
- s32 dst_y = dst_pos.Y + y0 ;
1770
- video::SColor src_c = src->getPixel (src_x, src_y);
1771
- video::SColor dst_c = dst->getPixel (dst_x, dst_y);
1772
- if (dst_c.getAlpha () > 0 && src_c.getAlpha () != 0 )
1773
- {
1774
- if (ratio == -1 )
1775
- dst_c = src_c.getInterpolated (dst_c, (float )src_c.getAlpha ()/255 .0f );
1776
- else
1777
- dst_c = src_c.getInterpolated (dst_c, (float )ratio/255 .0f );
1778
- dst->setPixel (dst_x, dst_y, dst_c);
1779
- }
1780
- }
1781
- }
1782
-
1783
1751
/*
1784
1752
Apply color to destination
1785
1753
*/
1786
- static void apply_colorize (video::IImage *dst, v2s32 dst_pos, v2u32 size,
1754
+ static void apply_colorize (video::IImage *dst, v2u32 dst_pos, v2u32 size,
1787
1755
video::SColor color, int ratio, bool keep_alpha)
1788
1756
{
1789
1757
u32 alpha = color.getAlpha ();
1790
1758
video::SColor dst_c;
1791
1759
if ((ratio == -1 && alpha == 255 ) || ratio == 255 ) { // full replacement of color
1792
1760
if (keep_alpha) { // replace the color with alpha = dest alpha * color alpha
1793
1761
dst_c = color;
1794
- for (s32 y = dst_pos.Y ; y < dst_pos.Y + size.Y ; y++)
1795
- for (s32 x = dst_pos.X ; x < dst_pos.X + size.X ; x++) {
1762
+ for (u32 y = dst_pos.Y ; y < dst_pos.Y + size.Y ; y++)
1763
+ for (u32 x = dst_pos.X ; x < dst_pos.X + size.X ; x++) {
1796
1764
u32 dst_alpha = dst->getPixel (x, y).getAlpha ();
1797
1765
if (dst_alpha > 0 ) {
1798
1766
dst_c.setAlpha (dst_alpha * alpha / 255 );
1799
1767
dst->setPixel (x, y, dst_c);
1800
1768
}
1801
1769
}
1802
1770
} else { // replace the color including the alpha
1803
- for (s32 y = dst_pos.Y ; y < dst_pos.Y + size.Y ; y++)
1804
- for (s32 x = dst_pos.X ; x < dst_pos.X + size.X ; x++)
1771
+ for (u32 y = dst_pos.Y ; y < dst_pos.Y + size.Y ; y++)
1772
+ for (u32 x = dst_pos.X ; x < dst_pos.X + size.X ; x++)
1805
1773
if (dst->getPixel (x, y).getAlpha () > 0 )
1806
1774
dst->setPixel (x, y, color);
1807
1775
}
1808
1776
} else { // interpolate between the color and destination
1809
1777
float interp = (ratio == -1 ? color.getAlpha () / 255 .0f : ratio / 255 .0f );
1810
- for (s32 y = dst_pos.Y ; y < dst_pos.Y + size.Y ; y++)
1811
- for (s32 x = dst_pos.X ; x < dst_pos.X + size.X ; x++) {
1778
+ for (u32 y = dst_pos.Y ; y < dst_pos.Y + size.Y ; y++)
1779
+ for (u32 x = dst_pos.X ; x < dst_pos.X + size.X ; x++) {
1812
1780
dst_c = dst->getPixel (x, y);
1813
1781
if (dst_c.getAlpha () > 0 ) {
1814
1782
dst_c = color.getInterpolated (dst_c, interp);
0 commit comments