Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/formats/gray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,30 @@ impl<T> core::ops::Deref for Gray_v08<T> {
&self.0
}
}

impl<T: Copy> Gray_v08<T> {
/// Reads the `.0` field
///
/// This is a compatibility shim. Migrate to `Gray_v09` and use `.v` directly.
#[deprecated(since = "0.8.91", note = "Use Gray_v09 with .v field instead")]
pub fn value(self) -> T {
self.0
}

/// Exposes the `.0` field for writing
///
/// This is a compatibility shim. Migrate to `Gray_v09` and use `.v` directly.
#[deprecated(since = "0.8.91", note = "Use Gray_v09 with .v field instead")]
pub fn value_mut(&mut self) -> &mut T {
&mut self.0
}

/// Add alpha component to this pixel
///
/// This is a compatibility shim. Migrate to `Gray_v09` and use `GrayA` instead.
#[deprecated(since = "0.8.91", note = "Use Gray_v09::with_alpha() or GrayA instead")]
#[allow(deprecated)]
pub fn with_alpha(self, add_alpha_value: T) -> crate::formats::gray_alpha::GrayAlpha_v08<T> {
crate::formats::gray_alpha::GrayAlpha_v08(self.0, add_alpha_value)
}
}
14 changes: 11 additions & 3 deletions src/formats/gray_alpha.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::formats::gray_a::GrayA;
use core::ops::Deref;
use core::ops::DerefMut;
use core::ops::{Deref, DerefMut};

#[repr(C)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down Expand Up @@ -45,10 +44,19 @@ impl<T, A> DerefMut for GrayAlpha_v08<T, A> {
impl<T: Clone, A> GrayAlpha_v08<T, A> {
/// Value - the brightness component. May be luma or luminance.
///
/// Backwards-compatible getter for `self.v`
/// This is a compatibility shim. Migrate to `GrayA` and use `.v` directly.
#[deprecated(since = "0.8.91", note = "Use GrayA with .v field instead")]
pub fn value(&self) -> T {
self.0.clone()
}

/// Exposes the `.0` field for writing
///
/// This is a compatibility shim. Migrate to `GrayA` and use `.v` directly.
#[deprecated(since = "0.8.91", note = "Use GrayA with .v field instead")]
pub fn value_mut(&mut self) -> &mut T {
&mut self.0
}
}

#[test]
Expand Down
Loading