public void displayImage(ImageParameters [] imageParameters, int nProblems, Graphics g, int rowHeight, boolean adaptImgSize, int windowWidth, int windowHeight)
	{
		int headerOffset = config.getShowHeader() ? 1 : 0;
		int footerOffset = config.getFooter() != null ? 1 : 0;
		int urbHeight = config.getShowHeader() ? config.getUpperRowBorderHeight() : 0;
		int curWindowHeight, offsetY;
		int maxW = -1, maxH = -1, nr;

		for(nr=0; nr<Math.min(config.getCamRows() * config.getCamCols(), imageParameters.length); nr++) {
			if (imageParameters[nr] == null)
				continue;

			maxW = Math.max(maxW, imageParameters[nr].getWidth());
			maxH = Math.max(maxH, imageParameters[nr].getHeight());
		}

		int totalWidth  = maxW * config.getCamCols();
		int totalHeight = maxH * config.getCamRows();

		if (adaptImgSize) {
			curWindowHeight = rowHeight * (config.getNRows() - (headerOffset + footerOffset + nProblems));
			offsetY = (headerOffset + footerOffset + nProblems) * rowHeight + urbHeight;
		}
		else if (config.getHeaderTransparency() != 1.0f) {
			curWindowHeight = windowHeight;
			offsetY = 0;
		}
		else {
			offsetY = rowHeight * headerOffset + urbHeight;
			curWindowHeight = rowHeight * (config.getNRows() - (headerOffset + footerOffset));
		}

		if (curWindowHeight > 0) {
			double wMul = (double)windowWidth / (double)totalWidth;
			double hMul = (double)curWindowHeight / (double)totalHeight;
			double multiplier = Math.min(wMul, hMul);
			double spacingX = maxW * multiplier;
			double spacingY = maxH * multiplier;

			int putX = Math.max(0, (windowWidth / 2) - ((int)spacingX / 2) * config.getCamCols());
			int putY = Math.max(0, (curWindowHeight / 2) - ((int)spacingY / 2) * config.getCamRows()) + offsetY;

			nr = 0;
			for(int y=0; y<config.getCamRows(); y++) {
				for(int x=0; x<config.getCamCols(); x++) {
					int plotX = putX + (int)(x * spacingX);
					int plotY = putY + (int)(y * spacingY);

					if (nr < imageParameters.length && imageParameters[nr] != null) {
						int curImgWidth = imageParameters[nr].getWidth();
						int curImgHeight = imageParameters[nr].getHeight();
						int newWidth  = (int)spacingX;
						int newHeight = (int)spacingY;
						if (config.getKeepAspectRatio()) {
							double curWMul = spacingX / curImgWidth;
							double curHMul = spacingY / curImgHeight;
							double curMultiplier = Math.min(curWMul, curHMul);
							newWidth  = (int)((double)curImgWidth  * curMultiplier);
							newHeight = (int)((double)curImgHeight * curMultiplier);
						}
						plotX += Math.max(0, spacingX - newWidth) / 2;
						plotY += Math.max(0, spacingY - newHeight) / 2;

						Image img = imageParameters[nr].getImage();

						if (g.drawImage(img, plotX, plotY, newWidth, newHeight, this) == false)
							CoffeeSaint.log.add("drawImage " + imageParameters[nr].getImage() + " returns false");
					}
					else {
						// g.drawString("n/a", plotX, plotY);
					}

					nr++;
				}
			}
		}
	}