the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 71 lines 1.7 kB view raw
1#include "stdafx.h" 2#include "MobSkinTextureProcessor.h" 3 4BufferedImage *MobSkinTextureProcessor::process(BufferedImage *in) 5{ 6 if (in == NULL) return NULL; 7 8 width = 64; 9 height = 32; 10 11 BufferedImage *out = new BufferedImage(width, height, BufferedImage::TYPE_INT_ARGB); 12 Graphics *g = out->getGraphics(); 13 g->drawImage(in, 0, 0, NULL); 14 g->dispose(); 15 16 pixels = out->getData(); 17 18 setNoAlpha(0, 0, 32, 16); 19 setForceAlpha(32, 0, 64, 32); 20 setNoAlpha(0, 16, 64, 32); 21 bool hasAlpha = false; 22 for (int x = 32; x < 64; x++) 23 for (int y = 0; y < 16; y++) 24 { 25 int pix = pixels[x + y * 64]; 26 if (((pix >> 24) & 0xff) < 128) hasAlpha = true; 27 } 28 29 if (!hasAlpha) 30 { 31 for (int x = 32; x < 64; x++) 32 for (int y = 0; y < 16; y++) 33 { 34 int pix = pixels[x + y * 64]; 35 if (((pix >> 24) & 0xff) < 128) hasAlpha = true; 36 } 37 } 38 39 return out; 40} 41 42void MobSkinTextureProcessor::setForceAlpha(int x0, int y0, int x1, int y1) 43{ 44 if (hasAlpha(x0, y0, x1, y1)) return; 45 46 for (int x = x0; x < x1; x++) 47 for (int y = y0; y < y1; y++) 48 { 49 pixels[x + y * width] &= 0x00ffffff; 50 } 51} 52 53void MobSkinTextureProcessor::setNoAlpha(int x0, int y0, int x1, int y1) 54{ 55 for (int x = x0; x < x1; x++) 56 for (int y = y0; y < y1; y++) 57 { 58 pixels[x + y * width] |= 0xff000000; 59 } 60} 61 62bool MobSkinTextureProcessor::hasAlpha(int x0, int y0, int x1, int y1) 63{ 64 for (int x = x0; x < x1; x++) 65 for (int y = y0; y < y1; y++) 66 { 67 int pix = pixels[x + y * width]; 68 if (((pix >> 24) & 0xff) < 128) return true; 69 } 70 return false; 71}