Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void buildFromPlanes(String name, File out) throws IOException {
- for (int i = 0; i < 4; i++) {
- FileInputStream in = new FileInputStream(new File(""+name+i+".dmp"));
- for (int j = 0; j< ((320*240)/4); j++) {
- planeData[i][j] = in.read();
- }
- in.close();
- }
- writeImage(out);
- }
- public void writeImage(File file) throws IOException {
- BufferedImage out = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
- int i = 0;
- for (int y = 0; y < height; y++) {
- for (int x = 0; x < width; x++) {
- int rgb = planeData[i%4][i/4];
- int red = (rgb >> 5) << 5;
- int green = ((rgb >> 2) & 7) << 5;
- int blue = (rgb & 3) << 6;
- int newRGB = (red << 16) + (green << 8) + blue;
- out.setRGB(x,y,newRGB);
- i++;
- }
- }
- ImageIO.write(out, "PNG", file);
- }
Advertisement
Add Comment
Please, Sign In to add comment