SHARE
TWEET

Untitled

a guest Oct 23rd, 2017 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package subspace;
  2.  
  3. import java.awt.image.BufferedImage;
  4.  
  5. import javax.imageio.ImageIO;
  6.  
  7.  
  8.  
  9. public class Art {
  10.     //public static Bitmap walls = loadBitmap("/tex/walls.png");
  11.     //public static Bitmap floors = loadBitmap("/tex/floors.png");
  12.        
  13.        
  14.     public static Bitmap loadBitmap(String fileName) {
  15.         try {
  16.             BufferedImage img = ImageIO.read(Art.class.getResource(fileName));
  17.  
  18.             int w = img.getWidth();
  19.             int h = img.getHeight();
  20.  
  21.             Bitmap result = new Bitmap(w, h);
  22.             img.getRGB(0, 0, w, h, result.pixels, 0, w);
  23.             for (int i = 0; i < result.pixels.length; i++) {
  24.                 int in = result.pixels[i];
  25.                 int col = (in & 0xf) >> 2;
  26.                 if (in == 0xffff00ff) col = -1;
  27.                 result.pixels[i] = col;
  28.                                 System.out.printf("pixels -->"+ result.pixels);
  29.             }
  30.             return result;
  31.         } catch (Exception e) {
  32.             throw new RuntimeException(e);
  33.         }
  34.     }
  35.  
  36.     public static int getCol(int c) {
  37.         int r = (c >> 16) & 0xff;
  38.         int g = (c >> 8) & 0xff;
  39.         int b = (c) & 0xff;
  40.  
  41.         r = r * 0x55 / 0xff;
  42.         g = g * 0x55 / 0xff;
  43.         b = b * 0x55 / 0xff;
  44.  
  45.         return r << 16 | g << 8 | b;
  46.     }
  47. }
RAW Paste Data
Top