def displayRangeToBricon(dataRange, displayRange):
    """Converts the given brightness/contrast values to a display range,
    given the data range.

    :arg dataRange:    The full range of the data being displayed, a
                       (min, max) tuple.

    :arg displayRange: A (min, max) tuple containing the display range.
    """
    dmin, dmax = dataRange
    dlo, dhi = displayRange
    drange = dmax - dmin
    dmid = dmin + 0.5 * drange
    if drange == 0:
        return 0, 0
    offset = dlo + 0.5 * (dhi - dlo) - dmid
    scale = (dhi - dlo) / drange
    brightness = 0.5 * (offset / drange + 1)
    if scale <= 1:
        contrast = scale / 2.0
    else:
        contrast = ((scale + 0.25) / 20.0) ** 0.25
    brightness = 1.0 - brightness
    contrast = 1.0 - contrast
    return brightness, contrast
