Guest User

Untitled

a guest
May 30th, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1.    
  2.  
  3.             public void buildFromPlanes(String name, File out) throws IOException {
  4.                     for (int i = 0; i < 4; i++) {
  5.                             FileInputStream in = new FileInputStream(new File(""+name+i+".dmp"));
  6.                             for (int j = 0; j< ((320*240)/4); j++) {
  7.                                     planeData[i][j] = in.read();
  8.                             }
  9.                             in.close();
  10.                     }
  11.                     writeImage(out);
  12.             }      
  13.      
  14.             public void writeImage(File file) throws IOException {
  15.                     BufferedImage out = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
  16.                     int i = 0;
  17.                     for (int y = 0; y < height; y++) {
  18.                             for (int x = 0; x < width; x++) {
  19.                                     int rgb = planeData[i%4][i/4];
  20.                                     int red = (rgb >> 5) << 5;
  21.                                     int green = ((rgb >> 2) & 7) << 5;
  22.                                     int blue = (rgb & 3) << 6;
  23.                                     int newRGB = (red << 16) + (green << 8) + blue;
  24.                                    
  25.                                     out.setRGB(x,y,newRGB);
  26.                                     i++;
  27.                             }
  28.                     }
  29.                    
  30.                     ImageIO.write(out, "PNG", file);
  31.             }
Advertisement
Add Comment
Please, Sign In to add comment