def computeDrawingArea(windowWidth, windowHeight, imageWidth, imageHeight):
    """ Determine how to draw the image at the center of the window as large as
        possible and without cropping. Returns (x, y, width, height) of the
        computed area.
    """
    if windowWidth * imageHeight > windowHeight * imageWidth:
        # ih/iw > wh/ww: image size bounded by height
        width = imageWidth * windowHeight / imageHeight
        height = windowHeight
        x = (windowWidth - width) / 2
        y = 0
    else:
        # ih/iw <= wh/ww: image size bounded by width
        width = windowWidth
        height = imageHeight * windowWidth / imageWidth
        x = 0
        y = (windowHeight - height) / 2
    return (x, y, width, height)