@@ -1783,9 +1783,48 @@ bool TextureSource::generateImagePart(std::string part_of_name,
1783
1783
for (u32 y = 0 ; y < dim.Height ; y++)
1784
1784
for (u32 x = 0 ; x < dim.Width ; x++)
1785
1785
{
1786
- video::SColor c = baseimg->getPixel (x,y);
1786
+ video::SColor c = baseimg->getPixel (x, y);
1787
1787
c.setAlpha (floor ((c.getAlpha () * ratio) / 255 + 0.5 ));
1788
- baseimg->setPixel (x,y,c);
1788
+ baseimg->setPixel (x, y, c);
1789
+ }
1790
+ }
1791
+ /*
1792
+ [invert:mode
1793
+ Inverts the given channels of the base image.
1794
+ Mode may contain the characters "r", "g", "b", "a".
1795
+ Only the channels that are mentioned in the mode string
1796
+ will be inverted.
1797
+ */
1798
+ else if (str_starts_with (part_of_name, " [invert:" )) {
1799
+ if (baseimg == NULL ) {
1800
+ errorstream << " generateImagePart(): baseimg == NULL "
1801
+ << " for part_of_name=\" " << part_of_name
1802
+ << " \" , cancelling." << std::endl;
1803
+ return false ;
1804
+ }
1805
+
1806
+ Strfnd sf (part_of_name);
1807
+ sf.next (" :" );
1808
+
1809
+ std::string mode = sf.next (" " );
1810
+ u32 mask = 0 ;
1811
+ if (mode.find (" a" ) != std::string::npos)
1812
+ mask |= 0xff000000UL ;
1813
+ if (mode.find (" r" ) != std::string::npos)
1814
+ mask |= 0x00ff0000UL ;
1815
+ if (mode.find (" g" ) != std::string::npos)
1816
+ mask |= 0x0000ff00UL ;
1817
+ if (mode.find (" b" ) != std::string::npos)
1818
+ mask |= 0x000000ffUL ;
1819
+
1820
+ core::dimension2d<u32> dim = baseimg->getDimension ();
1821
+
1822
+ for (u32 y = 0 ; y < dim.Height ; y++)
1823
+ for (u32 x = 0 ; x < dim.Width ; x++)
1824
+ {
1825
+ video::SColor c = baseimg->getPixel (x, y);
1826
+ c.color ^= mask;
1827
+ baseimg->setPixel (x, y, c);
1789
1828
}
1790
1829
}
1791
1830
else
0 commit comments