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