private void preparePalettes() {
   if (oldPalette == null || newPalette == null) {
     throw new NullPointerException("Both palettes must be set.");
   }
   inversePalette = new HashMap<>();
   for (int i = 0; i < newPalette.size(); i++) {
     inversePalette.put(newPalette.get(i), i);
   }
   changedColors = ColorHelper.findChangedColors(newPalette, oldPalette);
 }
 private Grid<Integer> loadPlainImage(
     Class resourceLoader, String resourceName, String propertiesName)
     throws ResourceMissingException {
   Map<String, Integer> mapping = null;
   if (propertiesName != null) {
     mapping = new HashMap<>();
     Properties prop = ResourceUtils.getResourceAsProperties(resourceLoader, propertiesName);
     for (String key : prop.stringPropertyNames()) {
       String rKey = key;
       if (key.startsWith("0x") || key.startsWith("0X")) {
         rKey = String.copyValueOf(Character.toChars(Integer.parseInt(key.substring(2), 16)));
       }
       String what = prop.getProperty(key);
       Integer ready;
       try {
         ready = ColorHelper.makeColor(what);
       } catch (InvalidStringFormatException ex) {
         throw new RuntimeException(ex);
       }
       mapping.put(rKey, ready);
     }
   }
   return ResourceUtils.getResourceAsGrid(resourceLoader, resourceName, mapping, false);
 }