codecs.py 文件源码

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

项目:pytoshop 作者: mdboom 项目源码 文件源码
def compress_constant_zip_prediction(fd,      # type: BinaryIO
                                     value,   # type: int
                                     width,   # type: int
                                     rows,    # type: int
                                     depth,   # type: int
                                     version  # type: int
                                     ):       # type: (...) -> np.ndarray
    """
    Write a virtual image containing a constant to a zip with
    prediction compressed stream.

{}
    """
    if depth == 1:  # pragma: no cover
        raise ValueError(
            "zip with prediction is not supported for 1-bit images")
    elif depth == 32:  # pragma: no cover
        raise ValueError(
            "zip with prediction is not implemented for 32-bit images")
    elif depth == 8:
        encoder = packbits.encode_prediction_8bit
    elif depth == 16:
        encoder = packbits.encode_prediction_16bit

    row = _make_constant_row(value, width, depth)
    row = row.reshape((1, width))
    row = util.ensure_native_endian(row)
    encoder(row.flatten())
    row = util.ensure_bigendian(row)
    row = row.tobytes()
    fd.write(zlib.compress(row * rows))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号