Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
This commit removes the implemented functions. Also updates the README.md description.
  • Loading branch information
jpburnett committed Apr 3, 2024
1 parent 744682e commit f314959
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# pigment64
pigment64 is a library written in Rust for decoding N64 images in to pngs.
pigment64 is a library written in Rust for converting image data between native and png formats.

## Formats
The library supports the following image formats:
Expand Down
48 changes: 11 additions & 37 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ pub use image::png_image::PNGImage;

mod utils;

use strum:: {
EnumCount, IntoEnumIterator
};
use strum_macros::{EnumCount as EnumCountMacro, EnumIter};
use strum_macros::{EnumCount, EnumIter};

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TryFromPrimitive)]
#[repr(u8)]
Expand All @@ -26,6 +23,15 @@ pub enum ImageSize {
}

impl ImageSize {
/// Returns the size of the TLUT (Table Look-Up Table) based on the image size.
///
/// # Returns
///
/// The size of the TLUT as a `usize` value.
///
/// # Panics
///
/// This method will panic if the image size is invalid.
pub fn get_tlut_size(&self) -> usize {
match self {
ImageSize::Bits1 => 0b10,
Expand Down Expand Up @@ -55,7 +61,7 @@ pub enum ImageFormat {
/// Each variant corresponds to a specific image type, such as indexed color (Ci), grayscale (I),
/// grayscale with alpha (Ia), or red-green-blue-alpha (RGBA).
///
#[derive(Copy, Clone, Debug, PartialEq, EnumCountMacro, EnumIter, Eq, Hash, TryFromPrimitive)]
#[derive(Copy, Clone, Debug, PartialEq, EnumCount, EnumIter, Eq, Hash, TryFromPrimitive)]
#[repr(u8)]
pub enum ImageType {
I1,
Expand Down Expand Up @@ -116,38 +122,6 @@ impl ImageType {
ImageType::Rgba32 => ImageFormat::Rgba,
}
}

/// Returns the number of variants in the `ImageType` enum.
///
/// # Examples
///
/// ```
/// use pigment64::ImageType;
///
/// // Get the count of ImageType variants
/// let count = ImageType::get_image_type_count();
/// println!("Number of ImageType variants: {}", count);
/// ```
pub fn get_count() -> usize {
ImageType::COUNT
}

/// Returns an iterator over all possible variants of `ImageType`, converted to their formatted
/// string representations.
///
/// # Examples
/// ```
/// use pigment64::ImageType;
///
/// // Iterate over the image formats
/// for image_format_type in ImageType::format_iter() {
/// println!("{}", image_format_type);
/// }
/// ```
pub fn get_iter() -> impl Iterator<Item = ImageType> {
ImageType::iter().into_iter()
}

}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive)]
Expand Down
3 changes: 2 additions & 1 deletion tests/native_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,9 @@ fn rgba32() -> Result<()> {
}

#[test]
fn test_format_names() {
fn test_image_type_strum() {

// Test iterating over the ImageType enum
let mut image_iter = ImageType::iter();
assert_eq!(Some(ImageType::I1), image_iter.next());
assert_eq!(Some(ImageType::I4), image_iter.next());
Expand Down

0 comments on commit f314959

Please sign in to comment.