the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 72 lines 1.8 kB view raw
1#include "stdafx.h" 2#include "MobSkinMemTextureProcessor.h" 3 4BufferedImage *MobSkinMemTextureProcessor::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 // 4J-PB - looks like the code below is wrong, and really should be looping from 0 to <32 30 if (!hasAlpha) 31 { 32 for (int x = 32; x < 64; x++) 33 for (int y = 0; y < 16; y++) 34 { 35 int pix = pixels[x + y * 64]; 36 if (((pix >> 24) & 0xff) < 128) hasAlpha = true; 37 } 38 } 39 40 return out; 41} 42 43void MobSkinMemTextureProcessor::setForceAlpha(int x0, int y0, int x1, int y1) 44{ 45 if (hasAlpha(x0, y0, x1, y1)) return; 46 47 for (int x = x0; x < x1; x++) 48 for (int y = y0; y < y1; y++) 49 { 50 pixels[x + y * width] &= 0x00ffffff; 51 } 52} 53 54void MobSkinMemTextureProcessor::setNoAlpha(int x0, int y0, int x1, int y1) 55{ 56 for (int x = x0; x < x1; x++) 57 for (int y = y0; y < y1; y++) 58 { 59 pixels[x + y * width] |= 0xff000000; 60 } 61} 62 63bool MobSkinMemTextureProcessor::hasAlpha(int x0, int y0, int x1, int y1) 64{ 65 for (int x = x0; x < x1; x++) 66 for (int y = y0; y < y1; y++) 67 { 68 int pix = pixels[x + y * width]; 69 if (((pix >> 24) & 0xff) < 128) return true; 70 } 71 return false; 72}