This commit is contained in:
bendn 2024-01-23 07:21:17 +07:00
parent 698f8d468a
commit 9210b2500f
No known key found for this signature in database
GPG key ID: 0D9D3A2A3B2A93D6
5 changed files with 11 additions and 16 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "fimg"
version = "0.4.32"
version = "0.4.33"
authors = ["bend-n <bend.n@outlook.com>"]
license = "MIT"
edition = "2021"

View file

@ -207,10 +207,10 @@ unsafe fn transpose<const CHANNELS: usize, T: AsMut<[u8]> + AsRef<[u8]>>(
) {
debug_assert_eq!(img.width(), img.height());
if img.width().is_power_of_two() {
// SAFETY: caller gurantees
// SAFETY: caller guarantees
unsafe { transpose_diag(img, 0, img.width() as usize) };
} else {
// SAFETY: caller gurantees
// SAFETY: caller guarantees
unsafe { transpose_non_power_of_two(img) };
}
}

View file

@ -8,7 +8,8 @@
//!
//! - [`Image`]: the main image type.
//! - [`DynImage`]: This is the image type you use when, say, loading a png. You should immediately convert this into a
//! - [`ImageCloner`]: this is... a [`Image`], but about to be cloned. It just allows some simple out-of-place optimizations, that `.clone().op()` dont allow. (produce with [`Image::cloner`])
//! - [`ImageCloner`]: This is... a [`Image`], but about to be cloned. It just allows some simple out-of-place optimizations, that `.clone().op()` dont allow. (produce with [`Image::cloner`])
//! - [`uninit::Image`]: A uninitialized image. Used for performance optimization.
//!
//! ### Operations
//!
@ -283,7 +284,7 @@ impl<T, const CHANNELS: usize> Image<T, CHANNELS> {
/// # Safety
///
/// the output index is not guranteed to be in bounds
/// the output index is not guaranteed to be in bounds
#[inline]
fn at(&self, x: u32, y: u32) -> usize {
(self.width(), self.height()).at::<CHANNELS>(x, y)
@ -418,7 +419,7 @@ impl<T, const CHANNELS: usize> Image<T, CHANNELS> {
/// # Safety
///
/// the output index is not guranteed to be in bounds
/// the output index is not guaranteed to be in bounds
#[inline]
fn slice<U>(&self, x: u32, y: u32) -> Range<usize>
where

View file

@ -76,7 +76,7 @@ unsafe fn blit(rgb: &mut [u8], rgba: &[u8]) {
while dsti + 16 <= rgb.len() {
// SAFETY: i think it ok
let old: Simd<u8, 16> = Simd::from_slice(unsafe { rgb.get_unchecked(dsti..dsti + 16) });
// SAFETY: definetly ok
// SAFETY: definitly ok
let new: Simd<u8, 16> = Simd::from_slice(unsafe { rgba.get_unchecked(srci..srci + 16) });
let threshold = new.simd_ge(Simd::splat(128)).to_int().cast::<u8>();
@ -98,7 +98,7 @@ unsafe fn blit(rgb: &mut [u8], rgba: &[u8]) {
}
while dsti + 3 <= rgb.len() {
// SAFETY: caller gurantees slice is big enough
// SAFETY: caller guarantees slice is big enough
if unsafe { *rgba.get_unchecked(srci + 3) } >= 128 {
// SAFETY: slice is big enough!
let src = unsafe { rgba.get_unchecked(srci..=srci + 2) };

View file

@ -1,14 +1,8 @@
//! the houser of uninitialized memory. €$@!0В𴬔!℡
//!
//! contains [`Image`], an uninitialized image.
use std::{
hint::assert_unchecked,
mem::MaybeUninit,
num::NonZeroU32,
ops::{Index, IndexMut},
};
use crate::{span::Span, CopyWithinUnchecked};
use std::{hint::assert_unchecked, mem::MaybeUninit, num::NonZeroU32, ops::Index};
/// A uninitialized image. Be sure to initialize it!
pub struct Image<T: Copy, const CHANNELS: usize> {
@ -72,7 +66,7 @@ impl<T: Copy, const CHANNELS: usize> Image<T, CHANNELS> {
/// # Safety
///
/// the output index is not guranteed to be in bounds
/// the output index is not guaranteed to be in bounds
#[inline]
pub fn at(&self, x: u32, y: u32) -> usize {
crate::At::at::<CHANNELS>((self.width(), self.height()), x, y)