Enum serialimage::DynamicSerialImage

source ·
pub enum DynamicSerialImage {
    U8(SerialImageBuffer<u8>),
    U16(SerialImageBuffer<u16>),
    F32(SerialImageBuffer<f32>),
}
Expand description

Variants§

§

U8(SerialImageBuffer<u8>)

8-bit unsigned integer image data.

§

U16(SerialImageBuffer<u16>)

16-bit unsigned integer image data.

§

F32(SerialImageBuffer<f32>)

32-bit floating point image data.

Implementations§

source§

impl DynamicSerialImage

source

pub fn get_metadata(&self) -> Option<ImageMetaData>

Get the image metadata.

source

pub fn set_metadata(&mut self, meta: ImageMetaData)

Update the image metadata.

source

pub fn width(&self) -> usize

Get image width.

source

pub fn height(&self) -> usize

Get image height.

source

pub fn as_u8(&self) -> Option<&SerialImageBuffer<u8>>

Get the underlying SerialImageBuffer<u8> if the image is of type DynamicSerialImage::U8.

source

pub fn as_u16(&self) -> Option<&SerialImageBuffer<u16>>

Get the underlying SerialImageBuffer<u16> if the image is of type DynamicSerialImage::U16.

source

pub fn as_f32(&self) -> Option<&SerialImageBuffer<f32>>

Get the underlying SerialImageBuffer<f32> if the image is of type DynamicSerialImage::F32.

source

pub fn into_luma(&self) -> SerialImageBuffer<u16>

Convert the image to grayscale. The transformation used is 0.2162 * red + 0.7152 * green + 0.0722 * blue for converting RGB to grayscale (see here).

source

pub fn into_luma_alpha(&self) -> SerialImageBuffer<u16>

Convert the image to grayscale with alpha channel. The transformation used is 0.2162 * red + 0.7152 * green + 0.0722 * blue for converting RGB to grayscale (see here).

source

pub fn resize(self, nwidth: usize, nheight: usize, filter: FilterType) -> Self

Resize this image using the specified filter algorithm. Returns a new image. The image’s aspect ratio is preserved. The image is scaled to the maximum possible size that fits within the bounds specified by nwidth and nheight.

source

pub fn save(&self, path: &str) -> ImageResult<()>

Saves the buffer to a file at the path specified.

The image format is derived from the file extension. png, jpg, bmp, ico, tiff and exr files are supported.

source

pub fn savefits( &self, dir_prefix: &Path, file_prefix: &str, progname: Option<&str>, compress: bool, overwrite: bool ) -> Result<PathBuf, FitsError>

Available on crate feature fitsio only.

Save the image data to a FITS file.

§Arguments
  • dir_prefix - The directory where the file will be saved.
  • file_prefix - The prefix of the file name. The file name will be of the form {file_prefix}_{timestamp}.fits.
  • progname - The name of the program that generated the image.
  • compress - Whether to compress the FITS file.
  • overwrite - Whether to overwrite the file if it already exists.
§Errors
source§

impl DynamicSerialImage

source

pub fn from_vec_u8( width: usize, height: usize, data: Vec<u8> ) -> Result<Self, &'static str>

Create a new image from a vector of u8 pixels.

§Arguments
  • width - The width of the image.
  • height - The height of the image.
  • data - The image data as a vector of u8 pixels.
§Errors
  • Error messages as strings.

Note: The length of the vector must be width * height * channels.

  • For grayscale images, channels is 1.
  • For grayscale images with alpha channel, channels is 2.
  • For RGB images, channels is 3.
  • For RGBA images, channels is 4.
source

pub fn from_vec_u16( width: usize, height: usize, data: Vec<u16> ) -> Result<Self, &'static str>

Create a new image from a vector of u16 pixels.

§Arguments
  • width - The width of the image.
  • height - The height of the image.
  • data - The image data as a vector of u16 pixels.
§Errors
  • Error messages as strings.

Note: The length of the vector must be width * height * channels.

  • For grayscale images, channels is 1.
  • For grayscale images with alpha channel, channels is 2.
  • For RGB images, channels is 3.
  • For RGBA images, channels is 4.
source

pub fn from_vec_f32( width: usize, height: usize, data: Vec<f32> ) -> Result<Self, &'static str>

Create a new image from a vector of f32 pixels.

§Arguments
  • width - The width of the image.
  • height - The height of the image.
  • data - The image data as a vector of f32 pixels.
§Errors
  • Error messages as strings.

Note: The length of the vector must be width * height * channels. Grayscale images are not supported.

  • For RGB images, channels is 3.
  • For RGBA images, channels is 4.

Trait Implementations§

source§

impl Clone for DynamicSerialImage

source§

fn clone(&self) -> DynamicSerialImage

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for DynamicSerialImage

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for DynamicSerialImage

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<&DynamicImage> for DynamicSerialImage

source§

fn from(value: &DynamicImage) -> Self

Converts to this type from the input type.
source§

impl From<&DynamicSerialImage> for DynamicImage

source§

fn from(value: &DynamicSerialImage) -> Self

Converts to this type from the input type.
source§

impl From<&SerialImageBuffer<f32>> for DynamicSerialImage

source§

fn from(value: &SerialImageBuffer<f32>) -> Self

Converts to this type from the input type.
source§

impl From<&SerialImageBuffer<u16>> for DynamicSerialImage

source§

fn from(value: &SerialImageBuffer<u16>) -> Self

Converts to this type from the input type.
source§

impl From<&SerialImageBuffer<u8>> for DynamicSerialImage

source§

fn from(value: &SerialImageBuffer<u8>) -> Self

Converts to this type from the input type.
source§

impl From<DynamicImage> for DynamicSerialImage

source§

fn from(value: DynamicImage) -> DynamicSerialImage

Converts to this type from the input type.
source§

impl From<DynamicSerialImage> for DynamicImage

source§

fn from(value: DynamicSerialImage) -> Self

Converts to this type from the input type.
source§

impl From<SerialImageBuffer<f32>> for DynamicSerialImage

source§

fn from(value: SerialImageBuffer<f32>) -> Self

Converts to this type from the input type.
source§

impl From<SerialImageBuffer<u16>> for DynamicSerialImage

source§

fn from(value: SerialImageBuffer<u16>) -> Self

Converts to this type from the input type.
source§

impl From<SerialImageBuffer<u8>> for DynamicSerialImage

source§

fn from(value: SerialImageBuffer<u8>) -> Self

Converts to this type from the input type.
source§

impl PartialEq for DynamicSerialImage

source§

fn eq(&self, other: &DynamicSerialImage) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for DynamicSerialImage

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl TryInto<SerialImageBuffer<f32>> for &DynamicSerialImage

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<SerialImageBuffer<f32>, &'static str>

Performs the conversion.
source§

impl TryInto<SerialImageBuffer<f32>> for DynamicSerialImage

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<SerialImageBuffer<f32>, &'static str>

Performs the conversion.
source§

impl TryInto<SerialImageBuffer<u16>> for &DynamicSerialImage

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<SerialImageBuffer<u16>, &'static str>

Performs the conversion.
source§

impl TryInto<SerialImageBuffer<u16>> for DynamicSerialImage

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<SerialImageBuffer<u16>, &'static str>

Performs the conversion.
source§

impl TryInto<SerialImageBuffer<u8>> for &DynamicSerialImage

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<SerialImageBuffer<u8>, &'static str>

Performs the conversion.
source§

impl TryInto<SerialImageBuffer<u8>> for DynamicSerialImage

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<SerialImageBuffer<u8>, &'static str>

Performs the conversion.
source§

impl StructuralPartialEq for DynamicSerialImage

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,