private void setRows(BufferedImage image, Colour backgroundCol, HashMap<Color, Colour> colorMap, ArrayList<Row> rows) {
      for (int i = 0; i < image.getHeight(); i++) {
         Row row = new Row();
         row.setIndex(i);
         ArrayList<Block> blocks = new ArrayList<Block>();
         Block block = null;
         Integer blockSize = null;
         for (int j = 0; j < image.getWidth(); j++) {
            Color c = new Color(image.getRGB(j, i));
            Colour currentColour = colorMap.get(c);
            // noch kein Block, also neuen erstellen
            if (block == null) {
               if (!currentColour.equals(backgroundCol)) {
                  block = new Block();
                  block.setColour(currentColour);
                  blockSize = 1;
               }
               // bereits ein Block vorhanden
            } else {
               // nicht Hintergrundfarbe
               if (!currentColour.equals(backgroundCol)) {
                  // Farbe ist dieselbe, wie die des derzeitigen Blocks, also
                  // Groesse des Blocks erhoehen
                  if (currentColour.equals(block.getColour())) {
                     blockSize++;
                     // andere Farbe, also neuer Block
                  } else {
                     block.setHowMany(blockSize);
                     blocks.add(block);

                     block = new Block();
                     block.setColour(currentColour);
                     blockSize = 1;
                  }
                  // Hintergrundfarbe, also Block ist beendet
               } else {
                  block.setHowMany(blockSize);
                  blocks.add(block);
                  blockSize = null;
                  block = null;
               }
            }
         }
         if (block != null) {
            block.setHowMany(blockSize);
            blocks.add(block);
            block = null;
         }
         row.setBlocks(blocks);
         rows.add(row);
      }
   }