def adjustbufsize(
      bufsize: int, bits: int) -> int:
    """Adjust buffer size to
        account for bit depth

    Args:
        bufsize: initial estimate
                 of buffer size
        bits   : bit depth of bitmap
                 (1, 4, 8, 24) bits

    Returns:
        An adjusted int value of the
        buffer size
    """
    if bits == 1:
        bufsize >>= 3
    elif bits == 24:
        bufsize *= 3
    elif bits == 4:
        bufsize >>= 1
    return bufsize