diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/MobSkinTextureProcessor.cpp | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.Client/MobSkinTextureProcessor.cpp')
| -rw-r--r-- | Minecraft.Client/MobSkinTextureProcessor.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/Minecraft.Client/MobSkinTextureProcessor.cpp b/Minecraft.Client/MobSkinTextureProcessor.cpp new file mode 100644 index 00000000..dffb467a --- /dev/null +++ b/Minecraft.Client/MobSkinTextureProcessor.cpp @@ -0,0 +1,71 @@ +#include "stdafx.h" +#include "MobSkinTextureProcessor.h" + +BufferedImage *MobSkinTextureProcessor::process(BufferedImage *in) +{ + if (in == NULL) return NULL; + + width = 64; + height = 32; + + BufferedImage *out = new BufferedImage(width, height, BufferedImage::TYPE_INT_ARGB); + Graphics *g = out->getGraphics(); + g->drawImage(in, 0, 0, NULL); + g->dispose(); + + pixels = out->getData(); + + setNoAlpha(0, 0, 32, 16); + setForceAlpha(32, 0, 64, 32); + setNoAlpha(0, 16, 64, 32); + bool hasAlpha = false; + for (int x = 32; x < 64; x++) + for (int y = 0; y < 16; y++) + { + int pix = pixels[x + y * 64]; + if (((pix >> 24) & 0xff) < 128) hasAlpha = true; + } + + if (!hasAlpha) + { + for (int x = 32; x < 64; x++) + for (int y = 0; y < 16; y++) + { + int pix = pixels[x + y * 64]; + if (((pix >> 24) & 0xff) < 128) hasAlpha = true; + } + } + + return out; +} + +void MobSkinTextureProcessor::setForceAlpha(int x0, int y0, int x1, int y1) +{ + if (hasAlpha(x0, y0, x1, y1)) return; + + for (int x = x0; x < x1; x++) + for (int y = y0; y < y1; y++) + { + pixels[x + y * width] &= 0x00ffffff; + } +} + +void MobSkinTextureProcessor::setNoAlpha(int x0, int y0, int x1, int y1) +{ + for (int x = x0; x < x1; x++) + for (int y = y0; y < y1; y++) + { + pixels[x + y * width] |= 0xff000000; + } +} + +bool MobSkinTextureProcessor::hasAlpha(int x0, int y0, int x1, int y1) +{ + for (int x = x0; x < x1; x++) + for (int y = y0; y < y1; y++) + { + int pix = pixels[x + y * width]; + if (((pix >> 24) & 0xff) < 128) return true; + } + return false; +}
\ No newline at end of file |
