mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
Use the first frame from animated textures instead of discarding
This commit is contained in:
parent
5d459c0ff9
commit
dbba7bc2a5
|
|
@ -333,16 +333,17 @@ void AbstractTexturePack::loadName()
|
||||||
|
|
||||||
void AbstractTexturePack::checkTexSize() {
|
void AbstractTexturePack::checkTexSize() {
|
||||||
BufferedImage* img = getImageResource(L"dirt.png", true);
|
BufferedImage* img = getImageResource(L"dirt.png", true);
|
||||||
if (img != NULL) {
|
texSize = 16;
|
||||||
|
if (img != nullptr) {
|
||||||
int width = img->getWidth();
|
int width = img->getWidth();
|
||||||
int height = img->getHeight();
|
int height = img->getHeight();
|
||||||
if (width != height) {
|
if (width != height || width <= 0 || height <= 0) {
|
||||||
app.DebugPrintf("Warning: Texture pack contains texture with bad size: %d x %d\n", width, height);
|
app.DebugPrintf("Warning: Texture pack contains texture with bad size: %d x %d\n", width, height);
|
||||||
} else
|
__debugbreak();
|
||||||
|
}
|
||||||
|
else
|
||||||
texSize = width;
|
texSize = width;
|
||||||
delete img;
|
delete img;
|
||||||
} else {
|
|
||||||
texSize = 16;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -845,21 +846,25 @@ void AbstractTexturePack::generateStitched(unordered_map<wstring, Icon*> texture
|
||||||
int imgW = srcImg->getWidth();
|
int imgW = srcImg->getWidth();
|
||||||
int imgH = srcImg->getHeight();
|
int imgH = srcImg->getHeight();
|
||||||
if (imgW != texSize || imgH != texSize) {
|
if (imgW != texSize || imgH != texSize) {
|
||||||
|
if (imgH % texSize == 0) {
|
||||||
|
app.DebugPrintf("Texture %ls is animated! using first frame\n", i.first.c_str());
|
||||||
|
srcImg = srcImg->getSubimage(0, 0, texSize, texSize);
|
||||||
|
imgW = imgH = texSize;
|
||||||
|
}
|
||||||
|
else {
|
||||||
app.DebugPrintf("Texture %ls is wrong size! skipping\n", i.first.c_str());
|
app.DebugPrintf("Texture %ls is wrong size! skipping\n", i.first.c_str());
|
||||||
delete srcImg;
|
delete srcImg;
|
||||||
continue;
|
srcImg = grabFromDefault(i, defaultPixels, { defaultAtlas->getWidth(), defaultAtlas->getHeight() });
|
||||||
|
imgW = srcImg->getWidth();
|
||||||
|
imgH = srcImg->getHeight();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
texPixels = reinterpret_cast<Pixel*>(srcImg->getData());
|
texPixels = reinterpret_cast<Pixel*>(srcImg->getData());
|
||||||
|
|
||||||
for (int j = 0; j < imgH * imgW; j++) {
|
for (int j = 0; j < imgH * imgW; j++) {
|
||||||
Pixel* src = &texPixels[j];
|
Pixel* src = &texPixels[j];
|
||||||
Pixel* dst = &atlasPixels[(x + j % imgW) + (resW * (y + j / imgH))];
|
Pixel* dst = &atlasPixels[(x + j % imgW) + (resW * (y + j / imgH))];
|
||||||
// int imgx = j % imgW; // debugging vars
|
|
||||||
// int imgy = j / imgH;
|
|
||||||
// int dstx = x + imgx;
|
|
||||||
// int dsty = y + imgy;
|
|
||||||
|
|
||||||
//unsigned char tmp = src->r; // unblue everything for saving, unsure why they are flipped
|
//unsigned char tmp = src->r; // unblue everything for saving, unsure why they are flipped
|
||||||
//src->r = src->b;
|
//src->r = src->b;
|
||||||
|
|
@ -871,15 +876,6 @@ void AbstractTexturePack::generateStitched(unordered_map<wstring, Icon*> texture
|
||||||
delete srcImg;
|
delete srcImg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
for (int i = 0; i < resH * resW; i++) { // Magenta test
|
|
||||||
auto pix = &atlasPixels[i];
|
|
||||||
pix->r = 255;
|
|
||||||
pix->g = 0;
|
|
||||||
pix->b = 255;
|
|
||||||
pix->a = 255;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
delete defaultAtlas;
|
delete defaultAtlas;
|
||||||
|
|
||||||
// Uncomment these two lines and the unblue section above if you are debugging autostitching of the atlas!
|
// Uncomment these two lines and the unblue section above if you are debugging autostitching of the atlas!
|
||||||
|
|
@ -921,9 +917,18 @@ void AbstractTexturePack::generateStitched(unordered_map<wstring, Icon*> texture
|
||||||
int imgW = srcImg->getWidth();
|
int imgW = srcImg->getWidth();
|
||||||
int imgH = srcImg->getHeight();
|
int imgH = srcImg->getHeight();
|
||||||
if (imgW != texSize || imgH != texSize) {
|
if (imgW != texSize || imgH != texSize) {
|
||||||
|
if (imgH % texSize == 0) {
|
||||||
|
app.DebugPrintf("Texture %ls is animated! using first frame\n", i.first.c_str());
|
||||||
|
srcImg = srcImg->getSubimage(0, 0, texSize, texSize);
|
||||||
|
imgW = imgH = texSize;
|
||||||
|
}
|
||||||
|
else {
|
||||||
app.DebugPrintf("Texture %ls is wrong size! skipping\n", i.first.c_str());
|
app.DebugPrintf("Texture %ls is wrong size! skipping\n", i.first.c_str());
|
||||||
delete srcImg;
|
delete srcImg;
|
||||||
continue;
|
srcImg = grabFromDefault(i, defaultPixels, { defaultAtlas->getWidth(), defaultAtlas->getHeight() });
|
||||||
|
imgW = srcImg->getWidth();
|
||||||
|
imgH = srcImg->getHeight();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -932,10 +937,6 @@ void AbstractTexturePack::generateStitched(unordered_map<wstring, Icon*> texture
|
||||||
for (int j = 0; j < imgH * imgW; j++) {
|
for (int j = 0; j < imgH * imgW; j++) {
|
||||||
Pixel* src = &texPixels[j];
|
Pixel* src = &texPixels[j];
|
||||||
Pixel* dst = &atlasPixels[(x + j % imgW) + (resW * (y + j / imgH))];
|
Pixel* dst = &atlasPixels[(x + j % imgW) + (resW * (y + j / imgH))];
|
||||||
// int imgx = j % imgW; // debugging vars
|
|
||||||
// int imgy = j / imgH;
|
|
||||||
// int dstx = x + imgx;
|
|
||||||
// int dsty = y + imgy;
|
|
||||||
|
|
||||||
//unsigned char tmp = src->r; // unblue everything for saving, unsure why they are flipped
|
//unsigned char tmp = src->r; // unblue everything for saving, unsure why they are flipped
|
||||||
//src->r = src->b;
|
//src->r = src->b;
|
||||||
|
|
@ -958,8 +959,8 @@ void AbstractTexturePack::generateStitched(unordered_map<wstring, Icon*> texture
|
||||||
|
|
||||||
BufferedImage *AbstractTexturePack::getImageResource(const wstring& File, bool filenameHasExtension /*= false*/, bool bTitleUpdateTexture /*=false*/, const wstring &drive /*=L""*/)
|
BufferedImage *AbstractTexturePack::getImageResource(const wstring& File, bool filenameHasExtension /*= false*/, bool bTitleUpdateTexture /*=false*/, const wstring &drive /*=L""*/)
|
||||||
{
|
{
|
||||||
const char *pchTexture=wstringtofilename(File);
|
std::string pchTexture=wstringtofilename(File);
|
||||||
app.DebugPrintf("AbstractTexturePack::getImageResource - %s, drive is %s\n",pchTexture, wstringtofilename(drive));
|
app.DebugPrintf("AbstractTexturePack::getImageResource - %s, drive is %s\n", pchTexture.c_str(), wstringtofilename(drive).c_str());
|
||||||
|
|
||||||
return new BufferedImage(TexturePack::getResource(L"/" + File),filenameHasExtension,bTitleUpdateTexture,drive);
|
return new BufferedImage(TexturePack::getResource(L"/" + File),filenameHasExtension,bTitleUpdateTexture,drive);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue