Mekanism-tilera-Edition/common/mekanism/client/CapeBufferDownload.java
2013-06-28 18:01:00 -04:00

75 lines
1.8 KiB
Java

package mekanism.client;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import net.minecraft.client.renderer.IImageBuffer;
public class CapeBufferDownload implements IImageBuffer
{
private int[] imageData;
private int imageWidth;
private int imageHeight;
@Override
public BufferedImage parseUserSkin(BufferedImage bufferedImage)
{
if(bufferedImage == null)
{
return null;
}
imageWidth = bufferedImage.getWidth(null);
imageHeight = bufferedImage.getHeight(null);
BufferedImage imageBuffer = new BufferedImage(imageWidth, imageHeight, 2);
Graphics graphics = imageBuffer.getGraphics();
graphics.drawImage(bufferedImage, 0, 0, null);
graphics.dispose();
imageData = ((DataBufferInt)imageBuffer.getRaster().getDataBuffer()).getData();
boolean flag = false;
int i;
int j;
int k;
for(i = 32; i < 64; i++)
{
for(j = 0; j < 16; j++)
{
k = imageData[i + j * 64];
if((k >> 24 & 0xFF) >= 128)
{
continue;
}
flag = true;
}
}
if(!flag)
{
for(i = 32; i < 64; i++)
{
for(j = 0; j < 16; j++)
{
k = imageData[i + j * 64];
if((k >> 24 & 0xFF) >= 128)
{
continue;
}
flag = true;
}
}
}
return imageBuffer;
}
}