1
2
3
4
5
6 package cz.cuni.amis.pogamut.unreal.communication.worldview.map;
7
8 import cz.cuni.amis.pogamut.base3d.worldview.object.Location;
9
10 import java.awt.image.BufferedImage;
11 import java.io.File;
12 import java.io.IOException;
13 import javax.imageio.ImageIO;
14
15
16
17
18
19 public class MapInfo implements IUnrealMapInfo {
20 private String name = "";
21 public Location[] imagePoints = new Location[3];
22 public Location[] worldPoints = new Location[3];
23
24 public int width;
25 public int height;
26
27 public byte[] imgData;
28
29 public int getHeight() {
30 return height;
31 }
32
33 public String getName() {
34 return name;
35 }
36
37 public int getWidth() {
38 return width;
39 }
40
41 public byte[] getImgRGBData() {
42 return imgData;
43 }
44
45 public void setImage(String path) throws IOException {
46 BufferedImage img = null;
47 img = ImageIO.read(new File(path));
48
49 this.width = img.getWidth();
50 this.height = img.getHeight();
51
52 imgData = new byte[img.getHeight() * img.getWidth() * 3];
53
54 int pos = 0;
55
56 for (int row = img.getHeight() - 1; row >= 0; row--) {
57 for (int col = 0; col < img.getWidth(); col++) {
58 if (true) {
59 int pixel = img.getRGB(col, row);
60 imgData[pos++] = (byte) ((pixel >> 16) & 0xFF);
61 imgData[pos++] = (byte) ((pixel >> 8) & 0xFF);
62 imgData[pos++] = (byte) ((pixel >> 0) & 0xFF);
63
64
65
66
67 }
68 }
69 }
70 }
71
72 public void setImagePoint(int i, Location l) {
73 this.imagePoints[i] = new Location(l);
74 }
75
76 public void setName(String name) {
77 this.name = name;
78 }
79
80 public void setWorldPos(int i, Location l) {
81 this.worldPoints[i] = new Location(l);
82 }
83
84 public Location[] getImagePoints() {
85 return imagePoints;
86 }
87
88 public Location[] getWorldPoints() {
89 return worldPoints;
90 }
91
92
93 }