static Point calcFitSize(BufferedImage image, Component c) { int w = c.getWidth(), h = c.getHeight(); int iw = image.getWidth(), ih = image.getHeight(); double imgScale = max(doubleRatio(h, ih), doubleRatio(w, iw)); ret pt(iround(iw*imgScale), iround(ih*imgScale)); }