(width, height, paper_width, paper_height)
return matrix, res
Calcualte a fallback matrix. Basically the same as in matrix.py, should
    be merged somehow!
Calcualte a fallback matrix. Basically the same as in matrix.py, should
    be merged somehow!
Calcualte a fallback matrix . Basically the same as in matrix . py should be merged somehow!
def _fallback_matrix(width, height, paper_width, paper_height):
    """Calcualte a fallback matrix. Basically the same as in matrix.py, should
    be merged somehow!"""
    xres = width / float(paper_width)
    yres = height / float(paper_height)

    # Assume the smaller size fits better ...
    res = min(xres, yres)

    scan_width = width / res
    scan_height = height / res

    dx = (paper_width - scan_width) / 2.0
    dy = (paper_height - scan_height) / 2.0

    matrix = cairo.Matrix()

    # Center the image
    matrix.translate(dx, dy)
    matrix.scale(1.0 / res, 1.0 / res)

    matrix.invert()

    return matrix, res
def _fallback_matrix ( width , height , paper_width , paper_height ) : xres = width / float ( paper_width ) yres = height / float ( paper_height ) # Assume the smaller size fits better ... res = min ( xres , yres ) scan_width = width / res scan_height = height / res dx = ( paper_width - scan_width ) / 2.0 dy = ( paper_height - scan_height ) / 2.0 matrix = cairo . Matrix ( ) # Center the image matrix . translate ( dx , dy ) matrix . scale ( 1.0 / res , 1.0 / res ) matrix . invert ( ) return matrix , res