From 49b9b85079c0d6608c88497fcf5e07dc7eb851d2 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Wed, 10 Jul 2013 15:51:05 +1000 Subject: [PATCH] Add yuv and ycbcr skeleton modules --- src/color/color.rs | 4 ++++ src/color/ycbcr.rs | 24 ++++++++++++++++++++++++ src/color/yuv.rs | 26 ++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 src/color/ycbcr.rs create mode 100644 src/color/yuv.rs diff --git a/src/color/color.rs b/src/color/color.rs index 0abc932..2c3890f 100644 --- a/src/color/color.rs +++ b/src/color/color.rs @@ -17,11 +17,15 @@ pub use self::channel::{Channel, FloatChannel}; pub use self::hsv::{HSV, ToHSV, HSVA, ToHSVA}; pub use self::rgb::{RGB, ToRGB, RGBA, ToRGBA}; pub use self::srgb::{SRGB, SRGBA}; +pub use self::ycbcr::YCbCr; +pub use self::yuv::YUV; pub mod channel; pub mod hsv; pub mod rgb; pub mod srgb; +pub mod ycbcr; +pub mod yuv; pub trait Color { pub fn clamp(&self, lo: T, hi: T) -> Self; diff --git a/src/color/ycbcr.rs b/src/color/ycbcr.rs new file mode 100644 index 0000000..ea50180 --- /dev/null +++ b/src/color/ycbcr.rs @@ -0,0 +1,24 @@ +// Copyright 2013 The Lmath Developers. For a full listing of the authors, +// refer to the AUTHORS file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#[deriving(Clone, Eq)] +pub struct YCbCr { y: T, cb: T, cr: T } + +impl YCbCr { + #[inline] + pub fn new(y: T, cb: T, cr: T) -> YCbCr { + YCbCr { y: y, cb: cb, cr: cr } + } +} diff --git a/src/color/yuv.rs b/src/color/yuv.rs new file mode 100644 index 0000000..6eccf18 --- /dev/null +++ b/src/color/yuv.rs @@ -0,0 +1,26 @@ +// Copyright 2013 The Lmath Developers. For a full listing of the authors, +// refer to the AUTHORS file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// http://en.wikipedia.org/wiki/YUV + +#[deriving(Clone, Eq)] +pub struct YUV { y: T, u: T, v: T } + +impl YUV { + #[inline] + pub fn new(y: T, u: T, v: T) -> YUV { + YUV { y: y, u: u, v: v } + } +}