crate: add image support

This commit is contained in:
meh
2015-08-03 18:52:30 +02:00
parent 8d4ee5f8bf
commit 67b683169c
3 changed files with 26 additions and 0 deletions

View File

@ -26,6 +26,10 @@ software-scaling = ["ffmpeg-sys/swscale", "codec"]
libc = "0.1"
bitflags = "0.1"
[dependencies.image]
version = "*"
optional = true
[dependencies.ffmpeg-sys]
version = "2.7.0"

View File

@ -3,6 +3,7 @@
extern crate libc;
extern crate ffmpeg_sys as ffi;
#[macro_use] extern crate bitflags;
#[cfg(feature = "image")] extern crate image;
pub mod util;
pub use util::error::Error;

View File

@ -293,3 +293,24 @@ impl Clone for Video {
pub trait Component {
fn is_valid(format: format::Pixel) -> bool;
}
#[cfg(feature = "image")]
impl Component for ::image::Luma<u8> {
fn is_valid(format: format::Pixel) -> bool {
format == format::Pixel::GRAY8
}
}
#[cfg(feature = "image")]
impl Component for ::image::Rgb<u8> {
fn is_valid(format: format::Pixel) -> bool {
format == format::Pixel::RGB24
}
}
#[cfg(feature = "image")]
impl Component for ::image::Rgba<u8> {
fn is_valid(format: format::Pixel) -> bool {
format == format::Pixel::RGBA
}
}