forked from Mirrorlandia_minetest/minetest
Add [resize texture modifier Resizes the texture to the given dimensions.
This commit is contained in:
parent
95446f4b6d
commit
53e9587861
@ -279,6 +279,13 @@ Example:
|
|||||||
|
|
||||||
[combine:16x32:0,0=default_cobble.png:0,16=default_wood.png
|
[combine:16x32:0,0=default_cobble.png:0,16=default_wood.png
|
||||||
|
|
||||||
|
#### `[resize:<w>x<h>`
|
||||||
|
Resizes the texture to the given dimensions.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
default_sandstone.png^[resize:16x16
|
||||||
|
|
||||||
#### `[brighten`
|
#### `[brighten`
|
||||||
Brightens the texture.
|
Brightens the texture.
|
||||||
|
|
||||||
|
@ -1352,7 +1352,6 @@ bool TextureSource::generateImagePart(std::string part_of_name,
|
|||||||
u32 r1 = stoi(sf.next(","));
|
u32 r1 = stoi(sf.next(","));
|
||||||
u32 g1 = stoi(sf.next(","));
|
u32 g1 = stoi(sf.next(","));
|
||||||
u32 b1 = stoi(sf.next(""));
|
u32 b1 = stoi(sf.next(""));
|
||||||
std::string filename = sf.next("");
|
|
||||||
|
|
||||||
core::dimension2d<u32> dim = baseimg->getDimension();
|
core::dimension2d<u32> dim = baseimg->getDimension();
|
||||||
|
|
||||||
@ -1711,6 +1710,31 @@ bool TextureSource::generateImagePart(std::string part_of_name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
[resize:WxH
|
||||||
|
Resizes the base image to the given dimensions
|
||||||
|
*/
|
||||||
|
else if (str_starts_with(part_of_name, "[resize"))
|
||||||
|
{
|
||||||
|
if (baseimg == NULL) {
|
||||||
|
errorstream << "generateImagePart(): baseimg == NULL "
|
||||||
|
<< "for part_of_name=\""<< part_of_name
|
||||||
|
<< "\", cancelling." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Strfnd sf(part_of_name);
|
||||||
|
sf.next(":");
|
||||||
|
u32 width = stoi(sf.next("x"));
|
||||||
|
u32 height = stoi(sf.next(""));
|
||||||
|
core::dimension2d<u32> dim(width, height);
|
||||||
|
|
||||||
|
video::IImage* image = m_device->getVideoDriver()->
|
||||||
|
createImage(video::ECF_A8R8G8B8, dim);
|
||||||
|
baseimg->copyToScaling(image);
|
||||||
|
baseimg->drop();
|
||||||
|
baseimg = image;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
errorstream << "generateImagePart(): Invalid "
|
errorstream << "generateImagePart(): Invalid "
|
||||||
|
Loading…
Reference in New Issue
Block a user