private ScalingInfo getScalingInfo() {
        int panelWidth = getWidth();
        int panelHeight = getHeight();
        int srcWidth = srcImage.getWidth(null);
        int srcHeight = srcImage.getHeight(null);
        int targetWidth = srcWidth;
        int targetHeight = srcHeight;
        if (scaleLarger || srcWidth > panelWidth || srcHeight > panelHeight) {
            targetWidth = Math.round(panelHeight * (srcWidth / (float) srcHeight));
            if (targetWidth > panelWidth) {
                targetHeight = Math.round(panelWidth * (srcHeight / (float) srcWidth));
                targetWidth = panelWidth;
            } else
                targetHeight = panelHeight;
        }
        ScalingInfo info = new ScalingInfo();
        info.targetWidth = targetWidth;
        info.targetHeight = targetHeight;
        info.srcWidth = srcWidth;
        info.srcHeight = srcHeight;
        info.x = panelWidth / 2 - targetWidth / 2;
        info.y = panelHeight / 2 - targetHeight / 2;
        return info;
    }