3个版本
| 0.1.2 | 2020年3月15日 |
|---|---|
| 0.1.1 | 2020年3月7日 |
| 0.1.0 | 2020年3月1日 |
在图像类别中排名417
每月下载量356
在4个crate中使用(直接使用3个)
66KB
1.5K SLoC
libwebp
这是一个libwebp库的绑定。
用法
准备
# Cargo.toml
[dependencies]
libwebp = { version = "0.1.2", features = ["0_6"] }
简单解码
use libwebp::WebPDecodeRGBA;
let data: &[u8];
let (width, height, buf) = WebPDecodeRGBA(data).unwrap();
eprintln!("width = {}, height = {}", width, height);
eprintln!(
"top-left pixel: rgba({}, {}, {}, {})",
buf[0],
buf[1],
buf[2],
buf[3] as f64 / 255.0,
)
简单编码
use libwebp::WebPEncodeRGBA;
let buf: &[u8] = &[
255, 255, 255, 255, // white
255, 0, 0, 255, // red
0, 255, 0, 255, // green
0, 0, 255, 255, // blue
];
let data = WebPEncodeRGBA(buf, 2, 2, 8, 75.0).unwrap();
let lossless_data = WebPEncodeLosslessRGBA(buf, 2, 2, 8).unwrap();
最低支持的Rust版本(MSRV)
Rust 1.31.0
功能
demux... 启用libwebpdemux函数。mux... 启用libwebpmux函数。0_5... 启用 libwebp 0.5.0 中引入的函数。0_6... 启用 libwebp 0.6.0 中引入的函数。1_1... 启用 libwebp 1.1.0 中引入的函数。static... 静态链接到捆绑的libwebp。extern-types... 启用#![feature(extern_types)]。
链接
如果系统中找到了libwebp,则链接到库。否则,它将构建并链接到捆绑的libwebp。
在这些情况下,首选静态链接
- 针对musl目标。
- 交叉编译时。
static功能已开启。- 构建时将环境变量
LIBWEBP_SYS_STATIC设置为1
相关仓库
完整性
types.h-
WebPMalloc -
WebPFree
-
decode.h-
WebPGetDecoderVersion -
WebPGetInfo -
WebPDecode* -
WebPDecodeYUV -
WebPDecode*Into -
WebPDecodeYUVInto -
WEBP_CSP_MODE -
WebPIsPremultipliedMode -
WebPIsAlphaMode -
WebPIsRGBMode -
WebPRGBABuffer -
WebPYUVABuffer -
WebPDecBuffer -
WebPInitDecBuffer -
WebPFreeDecBuffer -
VP8StatusCode -
WebPIDecoder(内部内存) -
WebPIDecoder(外部内存) -
WebPINewDecoder(内部内存) -
WebPINewDecoder(外部内存) -
WebPINewRGB(内部内存) -
WebPINewRGB(外部内存) -
WebPINewYUVA(内部内存) -
WebPINewYUVA(外部内存) -
WebPIDelete -
WebPIAppend -
WebPIUpdate -
WebPIDecGetRGB -
WebPIDecGetYUVA -
WebPIDecodedArea -
WebPBitstreamFeatures -
WebPGetFeatures -
WebPDecoderOptions -
WebPDecoderConfig -
WebPInitDecoderConfig -
WebPIDecode -
WebPDecode
-
encode.h-
WebPGetEncoderVersion -
WebPEncode* -
WebPEncodeLossless* -
WebPImageHint -
WebPConfig -
WebPPreset -
WebPConfigInit -
WebPConfigPreset -
WebPConfigLosslessPreset -
WebPValidateConfig -
WebPAuxStats -
WebPWriterFunction -
WebPMemoryWriter -
WebPMemoryWriterInit -
WebPMemoryWriterClear -
WebPMemoryWrite -
WebPProgressHook -
WebPEncCSP -
WebPEncodingError -
WEBP_MAX_DIMENSION -
WebPPicture -
WebPPictureInit -
WebPPictureAlloc -
WebPPictureFree -
WebPPictureCopy -
WebPPlaneDistortion -
WebPPictureDistortion -
WebPPictureCrop -
WebPPictureView -
WebPPictureIsView -
WebPPictureRescale -
WebPPictureImportRGB -
WebPPictureImportRGBA -
WebPPictureImportRGBX -
WebPPictureImportBGR -
WebPPictureImportBGRA -
WebPPictureImportBGRX -
WebPPictureARGBToYUVA -
WebPPictureARGBToYUVADithered -
WebPPictureSharpARGBToYUVA -
WebPPictureSmartARGBToYUVA -
WebPPictureYUVAToARGB -
WebPCleanupTransparentArea -
WebPPictureHasTransparency -
WebPBlendAlpha -
WebPEncode
-
mux_types.h- 完全不
demux.h- 完全不
mux.h- 完全不
依赖项
~4MB
~73K SLoC