mirror of
https://github.com/Cykooz/fast_image_resize.git
synced 2026-10-08 01:11:09 +00:00
- Method PixelType::size() was made public.
- Fixed argument bounds for some methods.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
### Added
|
||||
|
||||
- Added Gaussian filter for convolution algorithm.
|
||||
- Method `PixelType::size()` was made public.
|
||||
|
||||
### Fixed
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::pixels::{
|
||||
};
|
||||
use crate::{
|
||||
try_pixel_type, DifferentDimensionsError, ImageView, ImageViewMut, IntoImageView,
|
||||
IntoImageViewMut, MappingError, PixelType,
|
||||
IntoImageViewMut, MappingError, PixelTrait, PixelType,
|
||||
};
|
||||
|
||||
pub fn change_type_of_pixel_components(
|
||||
@@ -48,8 +48,8 @@ fn change_components_type<S, D>(
|
||||
dst_image: &mut impl IntoImageViewMut,
|
||||
) -> Result<(), MappingError>
|
||||
where
|
||||
S: InnerPixel,
|
||||
D: InnerPixel<CountOfComponents = S::CountOfComponents>,
|
||||
S: PixelTrait,
|
||||
D: PixelTrait<CountOfComponents = S::CountOfComponents>,
|
||||
<S as InnerPixel>::Component: IntoPixelComponent<<D as InnerPixel>::Component>,
|
||||
{
|
||||
match (src_image.image_view::<S>(), dst_image.image_view_mut::<D>()) {
|
||||
|
||||
+4
-3
@@ -8,6 +8,7 @@ use crate::pixels::{
|
||||
};
|
||||
use crate::{
|
||||
try_pixel_type, ImageView, ImageViewMut, IntoImageView, IntoImageViewMut, MappingError,
|
||||
PixelTrait,
|
||||
};
|
||||
|
||||
pub(crate) mod mappers;
|
||||
@@ -96,11 +97,11 @@ where
|
||||
dst_image: &mut impl IntoImageViewMut,
|
||||
) -> Result<(), MappingError>
|
||||
where
|
||||
S: InnerPixel,
|
||||
S: PixelTrait,
|
||||
<S as InnerPixel>::Component: PixelComponent<CountOfComponentValues = Values<SIZE>>
|
||||
+ IntoPixelComponent<Out>
|
||||
+ Into<usize>,
|
||||
D: InnerPixel<Component = Out, CountOfComponents = S::CountOfComponents>,
|
||||
D: PixelTrait<Component = Out, CountOfComponents = S::CountOfComponents>,
|
||||
{
|
||||
let (src_view, dst_view) =
|
||||
match (src_image.image_view::<S>(), dst_image.image_view_mut::<D>()) {
|
||||
@@ -140,7 +141,7 @@ where
|
||||
) -> Result<(), MappingError>
|
||||
where
|
||||
Out: Into<usize>,
|
||||
S: InnerPixel<Component = Out>,
|
||||
S: PixelTrait<Component = Out>,
|
||||
{
|
||||
if let Some(image_view) = image.image_view_mut::<S>() {
|
||||
self.map_image_inplace_typed(image_view);
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
use crate::pixels::InnerPixel;
|
||||
use crate::{ArrayChunks, ImageError, PixelType};
|
||||
use crate::{ArrayChunks, ImageError, PixelTrait, PixelType};
|
||||
|
||||
/// A trait for getting access to image data.
|
||||
pub trait ImageView {
|
||||
@@ -99,12 +99,12 @@ pub trait IntoImageView {
|
||||
|
||||
fn height(&self) -> u32;
|
||||
|
||||
fn image_view<P: InnerPixel>(&self) -> Option<impl ImageView<Pixel = P>>;
|
||||
fn image_view<P: PixelTrait>(&self) -> Option<impl ImageView<Pixel = P>>;
|
||||
}
|
||||
|
||||
/// Conversion into an [ImageViewMut].
|
||||
pub trait IntoImageViewMut: IntoImageView {
|
||||
fn image_view_mut<P: InnerPixel>(&mut self) -> Option<impl ImageViewMut<Pixel = P>>;
|
||||
fn image_view_mut<P: PixelTrait>(&mut self) -> Option<impl ImageViewMut<Pixel = P>>;
|
||||
}
|
||||
|
||||
/// Returns supported by the crate pixels type of the image or `ImageError` if the image
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use crate::images::{TypedImage, TypedImageMut};
|
||||
use crate::pixels::InnerPixel;
|
||||
use crate::{
|
||||
ImageBufferError, ImageView, ImageViewMut, IntoImageView, IntoImageViewMut, PixelType,
|
||||
ImageBufferError, ImageView, ImageViewMut, IntoImageView, IntoImageViewMut, PixelTrait,
|
||||
PixelType,
|
||||
};
|
||||
|
||||
/// Simple reference to image data that provides [IntoImageView].
|
||||
@@ -257,13 +258,13 @@ impl<'a> IntoImageView for Image<'a> {
|
||||
self.height
|
||||
}
|
||||
|
||||
fn image_view<P: InnerPixel>(&self) -> Option<impl ImageView<Pixel = P>> {
|
||||
fn image_view<P: PixelTrait>(&self) -> Option<impl ImageView<Pixel = P>> {
|
||||
self.typed_image()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoImageViewMut for Image<'a> {
|
||||
fn image_view_mut<P: InnerPixel>(&mut self) -> Option<impl ImageViewMut<Pixel = P>> {
|
||||
fn image_view_mut<P: PixelTrait>(&mut self) -> Option<impl ImageViewMut<Pixel = P>> {
|
||||
self.typed_image_mut()
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -20,7 +20,8 @@ pub enum PixelType {
|
||||
}
|
||||
|
||||
impl PixelType {
|
||||
pub(crate) fn size(&self) -> usize {
|
||||
/// Returns pixel size in bytes.
|
||||
pub fn size(&self) -> usize {
|
||||
match self {
|
||||
Self::U8 => 1,
|
||||
Self::U8x2 => 2,
|
||||
|
||||
Reference in New Issue
Block a user