mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 06:58:11 +08:00
Upgrade to the Rust 2024 edition (#2367)
* Update to rust 2024 edition * Fixes * Clean up imports * Cargo fmt again --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
927d7dd9b2
commit
beb1c6ae64
@@ -1,9 +1,8 @@
|
||||
use crate::tiff::Ifd;
|
||||
use crate::tiff::file::TiffRead;
|
||||
use crate::tiff::tags::SonyDataOffset;
|
||||
use crate::tiff::Ifd;
|
||||
use crate::{RawImage, SubtractBlack, Transform};
|
||||
|
||||
use bitstream_io::{BitRead, BitReader, Endianness, BE};
|
||||
use bitstream_io::{BE, BitRead, BitReader, Endianness};
|
||||
use std::io::{Read, Seek};
|
||||
|
||||
pub fn decode_a100<R: Read + Seek>(ifd: Ifd, file: &mut TiffRead<R>) -> RawImage {
|
||||
@@ -63,11 +62,7 @@ fn ljpeg_diff<R: Read + Seek, E: Endianness>(huff: &[u16], file: &mut BitReader<
|
||||
|
||||
let diff = read_n_bits_from_file(length, file) as i32;
|
||||
|
||||
if length == 0 || (diff & (1 << (length - 1))) == 0 {
|
||||
diff - (1 << length) - 1
|
||||
} else {
|
||||
diff
|
||||
}
|
||||
if length == 0 || (diff & (1 << (length - 1))) == 0 { diff - (1 << length) - 1 } else { diff }
|
||||
}
|
||||
|
||||
fn sony_arw_load_raw<R: Read + Seek>(width: usize, height: usize, file: &mut BitReader<R, BE>) -> Option<Vec<u16>> {
|
||||
|
||||
@@ -3,7 +3,6 @@ use crate::tiff::tags::{BitsPerSample, CfaPattern, CfaPatternDim, Compression, I
|
||||
use crate::tiff::values::CurveLookupTable;
|
||||
use crate::tiff::{Ifd, TiffError};
|
||||
use crate::{RawImage, SubtractBlack, Transform};
|
||||
|
||||
use rawkit_proc_macros::Tag;
|
||||
use std::io::{Read, Seek};
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ use crate::tiff::file::TiffRead;
|
||||
use crate::tiff::tags::{BitsPerSample, BlackLevel, CfaPattern, CfaPatternDim, Compression, ImageLength, ImageWidth, RowsPerStrip, StripByteCounts, StripOffsets, Tag, WhiteBalanceRggbLevels};
|
||||
use crate::tiff::{Ifd, TiffError};
|
||||
use crate::{RawImage, SubtractBlack, Transform};
|
||||
|
||||
use rawkit_proc_macros::Tag;
|
||||
use std::io::{Read, Seek};
|
||||
|
||||
|
||||
@@ -7,17 +7,15 @@ pub mod processing;
|
||||
pub mod tiff;
|
||||
|
||||
use crate::metadata::identify::CameraModel;
|
||||
|
||||
use processing::{Pixel, PixelTransform, RawPixel, RawPixelTransform};
|
||||
use rawkit_proc_macros::Tag;
|
||||
use std::io::{Read, Seek};
|
||||
use thiserror::Error;
|
||||
use tiff::file::TiffRead;
|
||||
use tiff::tags::{Compression, ImageLength, ImageWidth, Orientation, StripByteCounts, SubIfd, Tag};
|
||||
use tiff::values::Transform;
|
||||
use tiff::{Ifd, TiffError};
|
||||
|
||||
use std::io::{Read, Seek};
|
||||
use thiserror::Error;
|
||||
|
||||
pub(crate) const CHANNELS_IN_RGB: usize = 3;
|
||||
pub(crate) type Histogram = [[usize; 0x2000]; CHANNELS_IN_RGB];
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use crate::tiff::file::TiffRead;
|
||||
use crate::tiff::tags::{Make, Model, Tag};
|
||||
use crate::tiff::{Ifd, TiffError};
|
||||
|
||||
use rawkit_proc_macros::Tag;
|
||||
use std::io::{Read, Seek};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{Pixel, RawImage, CHANNELS_IN_RGB};
|
||||
use crate::{CHANNELS_IN_RGB, Pixel, RawImage};
|
||||
|
||||
impl RawImage {
|
||||
pub fn convert_to_rgb_fn(&self) -> impl Fn(Pixel) -> [u16; CHANNELS_IN_RGB] {
|
||||
pub fn convert_to_rgb_fn(&self) -> impl Fn(Pixel) -> [u16; CHANNELS_IN_RGB] + use<> {
|
||||
let Some(camera_to_rgb) = self.camera_to_rgb else { todo!() };
|
||||
|
||||
move |pixel: Pixel| {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::{Histogram, Image, Pixel, CHANNELS_IN_RGB};
|
||||
use crate::{CHANNELS_IN_RGB, Histogram, Image, Pixel};
|
||||
use std::f64::consts::E;
|
||||
|
||||
impl Image<u16> {
|
||||
pub fn gamma_correction_fn(&self, histogram: &Histogram) -> impl Fn(Pixel) -> [u16; CHANNELS_IN_RGB] {
|
||||
pub fn gamma_correction_fn(&self, histogram: &Histogram) -> impl Fn(Pixel) -> [u16; CHANNELS_IN_RGB] + use<> {
|
||||
let percentage = self.width * self.height;
|
||||
|
||||
let mut white = 0;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{Histogram, Pixel, PixelTransform, RawImage, CHANNELS_IN_RGB};
|
||||
use crate::{CHANNELS_IN_RGB, Histogram, Pixel, PixelTransform, RawImage};
|
||||
|
||||
impl RawImage {
|
||||
pub fn record_histogram_fn(&self) -> RecordHistogram {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{RawImage, RawPixel, SubtractBlack};
|
||||
|
||||
impl RawImage {
|
||||
pub fn scale_to_16bit_fn(&self) -> impl Fn(RawPixel) -> u16 {
|
||||
pub fn scale_to_16bit_fn(&self) -> impl Fn(RawPixel) -> u16 + use<> {
|
||||
let black_level = match self.black {
|
||||
SubtractBlack::CfaGrid(x) => x,
|
||||
_ => unreachable!(),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{RawImage, RawPixel};
|
||||
|
||||
impl RawImage {
|
||||
pub fn scale_white_balance_fn(&self) -> impl Fn(RawPixel) -> u16 {
|
||||
pub fn scale_white_balance_fn(&self) -> impl Fn(RawPixel) -> u16 + use<> {
|
||||
let Some(mut white_balance) = self.white_balance else { todo!() };
|
||||
|
||||
if white_balance[1] == 0. {
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::RawPixel;
|
||||
use crate::{RawImage, SubtractBlack};
|
||||
|
||||
impl RawImage {
|
||||
pub fn subtract_black_fn(&self) -> impl Fn(RawPixel) -> u16 {
|
||||
pub fn subtract_black_fn(&self) -> impl Fn(RawPixel) -> u16 + use<> {
|
||||
match self.black {
|
||||
SubtractBlack::CfaGrid(black_levels) => move |pixel: RawPixel| pixel.value.saturating_sub(black_levels[2 * (pixel.row % 2) + (pixel.column % 2)]),
|
||||
_ => todo!(),
|
||||
|
||||
@@ -4,11 +4,10 @@ mod types;
|
||||
pub mod values;
|
||||
|
||||
use file::TiffRead;
|
||||
use tags::Tag;
|
||||
|
||||
use num_enum::{FromPrimitive, IntoPrimitive};
|
||||
use std::fmt::Display;
|
||||
use std::io::{Read, Seek};
|
||||
use tags::Tag;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)]
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use super::types::{Array, ConstArray, TagType, TypeByte, TypeIfd, TypeLong, TypeNumber, TypeOrientation, TypeSRational, TypeSShort, TypeShort, TypeSonyToneCurve, TypeString};
|
||||
use super::{Ifd, TagId, TiffError, TiffRead};
|
||||
|
||||
use std::io::{Read, Seek};
|
||||
|
||||
pub trait SimpleTag {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use std::io::{Read, Seek};
|
||||
|
||||
use super::file::TiffRead;
|
||||
use super::values::{CurveLookupTable, Rational, Transform};
|
||||
use super::{Ifd, IfdTagType, TiffError};
|
||||
use std::io::{Read, Seek};
|
||||
|
||||
pub struct TypeAscii;
|
||||
pub struct TypeByte;
|
||||
@@ -41,11 +40,7 @@ impl PrimitiveType for TypeAscii {
|
||||
|
||||
fn read_primitive<R: Read + Seek>(_: IfdTagType, file: &mut TiffRead<R>) -> Result<Self::Output, TiffError> {
|
||||
let value = file.read_ascii()?;
|
||||
if value.is_ascii() {
|
||||
Ok(value)
|
||||
} else {
|
||||
Err(TiffError::InvalidValue)
|
||||
}
|
||||
if value.is_ascii() { Ok(value) } else { Err(TiffError::InvalidValue) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user