Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.image.BufferedImage;
- import org.bukkit.map.MapCanvas;
- /**
- *
- * @author ECB2 (ECB2.biz)
- *
- */
- public class MapImage {
- private byte tag[];
- public MapImage(byte tag[])
- {
- this.tag = tag;
- }
- public MapImage(BufferedImage image)
- {
- this.tag = this.convertImage(image);
- }
- public byte getColor(int x, int y)
- {
- return tag[x + y * 128];
- }
- public void draw(MapCanvas canvas)
- {
- for(int x = 0; x < 128; x++)
- {
- for(int y = 0; y < 128; y++)
- {
- canvas.setPixel(x, y, this.getColor(x, y));
- }
- }
- }
- private byte[] convertImage(BufferedImage bi)
- {
- byte[] colorsArray = new byte[128*128];
- try{
- for(int x = 0; x < 128; x++)
- {
- for(int y = 0; y < 128; y++){
- byte c = (byte)ColorUtil.findId(new Color(bi.getRGB(x, y)));
- if(c==0||c==1||c==2||c==3) c = (byte)119;
- colorsArray[x + y * 128] = c;
- }
- }
- }catch(Exception ex){
- ex.printStackTrace();
- }
- return colorsArray;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement