changed width and height in Image struct from usize to u32
This commit is contained in:
parent
243e94a506
commit
bbbb85d5ba
|
@ -1,6 +1,6 @@
|
|||
//!
|
||||
//! This module provides the struct and basic functions to represent images.
|
||||
//! The image struct has the width and height dimensions of the image in px as usize.
|
||||
//! The image struct has the width and height dimensions of the image in px as u32.
|
||||
//! The pixels of the image itself are stored in a vector where a tuple with four elements represent the RGBA values of a pixel.
|
||||
//!
|
||||
//! A pixel is a tuple with four elements where the elements are RGBA. For convenience the tuple is as an generic Datatype specified
|
||||
|
@ -42,9 +42,9 @@ where
|
|||
T: Into<f32> + PartialEq + Default + Copy + From<u8> + PartialOrd,
|
||||
{
|
||||
///the width of the Picture in px
|
||||
width: usize,
|
||||
width: u32,
|
||||
///the height of the Picture in px
|
||||
height: usize,
|
||||
height: u32,
|
||||
///the raw RGBA data of the Picture where the RGBA values of an pixel is one tuple
|
||||
pixels: Vec<(T, T, T, T)>,
|
||||
///the absolute path where the picture is located
|
||||
|
@ -58,8 +58,8 @@ where
|
|||
{
|
||||
///gives an Image with specified values if the Vec matches the width times the height of the Image
|
||||
/// if the width and height dont make sense for the Image then will this function panic.
|
||||
pub fn new(width: usize, height: usize, pixels: Vec<(T, T, T, T)>, path: PathBuf) -> Self {
|
||||
if width * height != pixels.len() {
|
||||
pub fn new(width: u32, height: u32, pixels: Vec<(T, T, T, T)>, path: PathBuf) -> Self {
|
||||
if width * height != pixels.len() as u32 {
|
||||
panic!("The Image does not have the same number of pixel as width and height implies")
|
||||
} else {
|
||||
Self {
|
||||
|
@ -72,11 +72,11 @@ where
|
|||
}
|
||||
|
||||
/// Returns the width of the image
|
||||
pub fn width(&self) -> usize {
|
||||
pub fn width(&self) -> u32 {
|
||||
self.width
|
||||
}
|
||||
/// Returns the height of the image
|
||||
pub fn height(&self) -> usize {
|
||||
pub fn height(&self) -> u32 {
|
||||
self.height
|
||||
}
|
||||
/// Returns a specified pixel of the image
|
||||
|
|
Loading…
Reference in New Issue