From ddcdc8b8fb03c704ee7d6416b5ced4a7f1958373 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Fri, 16 Dec 2016 00:03:30 +0200 Subject: [PATCH] Added: Border duplication option to texture atlas builder. --HG-- branch : experimental-ui-scaling --- code/nel/tools/3d/build_interface/main.cpp | 28 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/code/nel/tools/3d/build_interface/main.cpp b/code/nel/tools/3d/build_interface/main.cpp index a8f854721..58c97e513 100644 --- a/code/nel/tools/3d/build_interface/main.cpp +++ b/code/nel/tools/3d/build_interface/main.cpp @@ -214,6 +214,7 @@ int main(int argc, char **argv) args.addArg("x", "extract", "", "Extract all interface elements from to ."); args.addAdditionalArg("output_filename", "PNG or TGA file to generate", true); args.addAdditionalArg("input_path", "Path that containts interfaces elements", false); + args.addArg("b", "border", "", "Duplicate icon border to allow bilinear filtering"); if (!args.parse(argc, argv)) return 1; @@ -227,6 +228,13 @@ int main(int argc, char **argv) existingUVfilename = args.getArg("s").front(); } + // + uint borderSize = 0; + if (args.haveArg("b")) + { + borderSize = 1; + } + // extract all interface elements bool extractElements = args.haveArg("x"); @@ -407,6 +415,18 @@ int main(int argc, char **argv) pBtmp->convertToType(CBitmap::RGBA); } + // duplicate icon border + if (borderSize > 0) + { + NLMISC::CBitmap *tmp = new NLMISC::CBitmap; + tmp->resize(pBtmp->getWidth(), pBtmp->getHeight()); + tmp->blit(pBtmp, 0, 0); + tmp->resample(tmp->getWidth() + borderSize * 2, tmp->getHeight() + borderSize * 2); + tmp->blit(pBtmp, borderSize, borderSize); + delete pBtmp; + pBtmp = tmp; + } + AllMaps[i] = pBtmp; } catch (const NLMISC::Exception &e) @@ -461,10 +481,10 @@ int main(int argc, char **argv) putIn (AllMaps[i], &GlobalTexture, x, y); putIn (AllMaps[i], &GlobalMask, x, y, false); - UVMin[i].U = (float)x; - UVMin[i].V = (float)y; - UVMax[i].U = (float)x+AllMaps[i]->getWidth(); - UVMax[i].V = (float)y+AllMaps[i]->getHeight(); + UVMin[i].U = (float)x + borderSize; + UVMin[i].V = (float)y + borderSize; + UVMax[i].U = (float)x + AllMaps[i]->getWidth() - borderSize; + UVMax[i].V = (float)y + AllMaps[i]->getHeight() - borderSize; #if 0 // Do not remove this is useful for debugging