Example #1
0
 private PaletteCollection(Palette[] palettes)
 {
     this.palettes = palettes;
 }
Example #2
0
 public static PaletteCollection FromStream(Stream stream)
 {
     BinaryReader binaryReader = new BinaryReader(stream);
     // The first byte is the number of palettes in the collection
     int count = binaryReader.ReadByte();
     stream.Seek(3, SeekOrigin.Current); // Three unknown bytes (padding?)
     Palette[] palettes = new Palette[count];
     // Load the palettes, which are stored sequentially in the PAL file
     for(int index = 0; index < count; ++index) {
         try {
             palettes[index] = Palette.FromStream(stream);
         } catch(PaletteException exception) {
             StringBuilder message = new StringBuilder();
             message.Append("Error while loading palette " + index + " of " + count);
             message.Append(" (" + exception.Message + ")");
             throw new PaletteException(message.ToString());
         }
     }
     return new PaletteCollection(palettes);
 }