test_pam.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:segno 作者: heuer 项目源码 文件源码
def pam_bw_as_matrix(buff, border):
    """\
    Returns the QR code as list of [0, 1] lists.

    :param io.BytesIO buff: Buffer to read the matrix from.
    """
    res = []
    data, size = _image_data(buff)
    for i, offset in enumerate(range(0, len(data), size)):
        if i < border:
            continue
        if i >= size - border:
            break
        row_data = bytearray(data[offset + border:offset + size - border])
        # Invert bytes since PAM uses 0x0 = black, 0x1 = white
        res.append([b ^ 0x1 for b in row_data])
    return res
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号