codecs.py 文件源码

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

项目:pytoshop 作者: mdboom 项目源码 文件源码
def decompress_raw(data,    # type: bytes
                   shape,   # type: Tuple[int, int]
                   depth,   # type: int
                   version  # type: int
                   ):       # type: (...) -> np.ndarray
    """
    Converts raw data to a Numpy array.

{}
    """
    depth = enums.ColorDepth(depth)

    dtype = color_depth_dtype_map[depth]
    itemsize = color_depth_size_map[depth]

    # Truncate the data to a multiple of the dtype size
    data = data[:(len(data) // itemsize) * itemsize]

    arr = np.frombuffer(data, dtype)

    if depth == 1:
        # Unpack 1-bit image data
        arr = np.unpackbits(arr)

    # Make 2-dimensional
    image = arr.reshape(shape)
    return image
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号