def briconToScaleOffset(brightness, contrast, drange):
    """Used by the :func:`briconToDisplayRange` and the :func:`applyBricon`
    functions.

    Calculates a scale and offset which can be used to transform a display
    range of the given size so that the given brightness/contrast settings
    are applied.

    :arg brightness: Brightness, between 0.0 and 1.0.
    :arg contrast:   Contrast, between 0.0 and 1.0.
    :arg drange:     Data range.
    """
    offset = (brightness * 2 - 1) * drange
    if contrast <= 0.5:
        scale = contrast * 2
    else:
        scale = 20 * contrast ** 4 - 0.25
    return scale, offset
