• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

src/H03-May-2022-833814

tests/H03-May-2022-

vendor/H03-May-2022-98,73877,621

.cargo-checksum.jsonH A D03-May-202289 11

.cargo_vcs_info.jsonH A D01-Jan-197074 65

.gitignoreH A D07-Nov-201719 22

.gitmodulesH A D13-Nov-201890 43

Cargo.tomlH A D01-Jan-19701 KiB3027

Cargo.toml.orig-cargoH A D13-Nov-2018524 2016

README.mdH A D07-Nov-2017930 3627

build.rsH A D13-Nov-20184.6 KiB152132

wrapper.hH A D15-Aug-2017110 43

README.md

1# libwebp-sys
2
3[bindgen](https://github.com/servo/rust-bindgen)'d FFI bindings to [libwebp](https://developers.google.com/speed/webp/docs/api).
4
5libwebp itself is built with cmake and linked statically.
6
7## Add manul ffi.rs
8
9add ffi.rs that generated by bindgen manually to avoid install llvm and clang in server
10
11## Usage
12
13Add the following to the Cargo.toml in your project:
14
15```
16[dependencies]
17libwebp-sys = "0.1"
18```
19
20and import useing extern crate:
21```
22extern crate libwebp_sys;
23```
24
25## Example
26Encode:
27```
28pub fn encode_webp(input_image: &[u8], width: u32, height: u32, quality: i32) -> Result<Vec<u8>> {
29    unsafe {
30	    let mut out_buf = Box::into_raw(Box::new(0u8)) as *mut _;
31	    let stride = width as i32 * 4;
32	    let len = WebPEncodeRGBA(input_image.as_ptr(), width as i32, height as i32, stride, quality as f32, &mut out_buf as *mut _);
33	    Ok(Vec::from_raw_parts(out_buf, len as usize, len as usize))
34    }
35}
36```