Advertisement
Guest User

Untitled

a guest
Nov 19th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. package net.anyspieceofinter.unnamedgameproject.graphics;
  2.  
  3. import java.io.IOException;
  4. import javax.imageio.ImageIO;
  5. import java.awt.image.BufferedImage;
  6.  
  7. public class Spritesheet {
  8.    
  9.     private String path;
  10.     public final int SIZE;
  11.     public int[] pixels;
  12.    
  13.     public static Spritesheet enviroment = new Spritesheet("/textures/enviroment.png", 200);
  14.    
  15.     public Spritesheet (String path, int size) {
  16.        
  17.         this.path = path;
  18.         SIZE = size;
  19.         pixels = new int[SIZE*SIZE];
  20.         loadImage();
  21.        
  22.     }
  23.    
  24.     private void loadImage () {
  25.        
  26.         try {
  27.            
  28.             BufferedImage image = ImageIO.read(Spritesheet.class.getResource(path));
  29.            
  30.             int w = image.getWidth();
  31.             int h = image.getHeight();
  32.            
  33.             image.getRGB(0, 0, w, h, pixels, 0, w);
  34.            
  35.         }
  36.        
  37.         catch (IOException e) {
  38.            
  39.             e.printStackTrace();
  40.        
  41.         }
  42.        
  43.     }
  44.    
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement