public static IndexedImage load(byte[] data){
  try {
    DataInputStream input=new DataInputStream(new ByteArrayInputStream(data));
    int width=input.readShort();
    int height=input.readShort();
    int[] palette=new int[input.readByte() & 0xff];
    int plen=palette.length;
    for (int iter=0; iter < plen; iter++) {
      palette[iter]=input.readInt();
    }
    byte[] arr=new byte[width * height];
    input.readFully(arr);
    return new IndexedImage(width,height,palette,arr);
  }
 catch (  IOException ex) {
    ex.printStackTrace();
    return null;
  }
}

public static IndexedImage load ( byte [ ] data ) { try { DataInputStream input = new DataInputStream ( new ByteArrayInputStream ( data ) ) ; int width = input . readShort ( ) ; int height = input . readShort ( ) ; int [ ] palette = new int [ input . readByte ( ) & 0xff ] ; int plen = palette . length ; for ( int iter = 0 ; iter < plen ; iter ++ ) { palette [ iter ] = input . readInt ( ) ; } byte [ ] arr = new byte [ width * height ] ; input . readFully ( arr ) ; return new IndexedImage ( width , height , palette , arr ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; return null ; } }
loads a packaged image that was stored in a stream using the tobytearray method
