Skip to content
Snippets Groups Projects
Verified Commit 33c23fef authored by Louis's avatar Louis :fire:
Browse files

Fix imports for commands

parent da178981
No related branches found
No related tags found
No related merge requests found
Pipeline #728 waiting for manual action with stages
in 1 minute and 12 seconds
use crate::format::load_image;
use clap::Parser;
use etagere::{AllocId, AtlasAllocator, Rectangle, Size};
use image::{image_dimensions, GenericImage, Rgba, RgbaImage};
......@@ -9,6 +8,7 @@ use std::collections::HashMap;
use std::fmt::Display;
use std::fs::File;
use std::path::PathBuf;
use crunch_cli::utils::load_image;
fn default_max_size() -> usize {
2048
......
use crate::utils::{RgbaOutputFormat, SpriteData};
use clap::Parser;
use image::math::Rect;
......@@ -6,6 +5,7 @@ use image::{GenericImage, GenericImageView, Rgba, RgbaImage};
use serde::{Deserialize, Serialize};
use std::ops::Deref;
use crunch_cli::utils::{RgbaOutputFormat, SpriteData};
#[inline(always)]
fn tile_size() -> u32 {
......@@ -92,7 +92,8 @@ impl Extrude {
);
let mut new_image = RgbaImage::from_pixel(new_width, new_height, Rgba::from([0, 0, 0, 0]));
for sprite in views.iter() {
let (img_x, img_y, width, height) = sprite.data.bounds();
let (width, height) = sprite.data.dimensions();
let (img_x, img_y) = sprite.data.offsets();
let target_x = self.padding + img_x + (sprite.tx * self.space_x);
let target_y = self.padding + img_y + (sprite.ty * self.space_y);
......
use crate::utils::TypedOutputFormat;
use clap::{Parser, ValueEnum};
use image::{imageops, GenericImage, Pixel};
use serde::{Deserialize, Serialize};
use crunch_cli::utils::TypedOutputFormat;
#[derive(Copy, Clone, Serialize, Deserialize, ValueEnum, Debug)]
pub enum FlipDirection {
......
......@@ -5,12 +5,9 @@ use std::path::{Path, PathBuf};
use rayon::prelude::*;
use serde::{Deserialize, Serialize};
use thiserror::Error;
use crunch_cli::utils::{load_image, make_paths, normalize_path, ColourPalette, PaletteMap};
use crate::cli_args::Args;
use crate::commands::{Palette, Remap};
use crate::format::make_paths;
use crate::load_image;
use crate::utils::normalize_path;
#[derive(Error, Debug)]
pub enum PipelineError {
......@@ -135,10 +132,10 @@ impl Pipeline {
}
Args::Remap(remap) => {
let palette = result!(load_image(&remap.palette, None));
let image_palette = result!(Palette::extract_from(&file));
let target_palette = result!(Palette::extract_from(&palette));
let image_palette = ColourPalette::from(&file);
let target_palette = ColourPalette::from(&palette);
let mappings = Palette::calculate_mapping(&image_palette, &target_palette);
let mappings = PaletteMap::calculate_mapping(&image_palette, &target_palette);
file = result!(Remap::remap_image(file, mappings));
}
_ => {}
......
use crate::utils::RgbaOutputFormat;
use anyhow::Error;
use clap::Parser;
use image::GenericImage;
use serde::{Deserialize, Serialize};
use crunch_cli::utils::RgbaOutputFormat;
/// Limit the number of colours by quantity or threshold
#[derive(Debug, Clone, Parser, Serialize, Deserialize)]
......
use crate::commands::palette::ColourMapping;
use clap::Parser;
use image::{GenericImage, Pixel, Rgba};
use num_traits::ToPrimitive;
use serde::{Deserialize, Serialize};
use crate::utils::{new_image, BasicRgba, OutputFormat};
use crunch_cli::utils::{new_image, BasicRgba, OutputFormat, PaletteMap};
/// Convert the colour space of an image to that of a given palette file
#[derive(Debug, Clone, Parser, Serialize, Deserialize)]
......@@ -25,7 +23,7 @@ pub struct Remap {
impl Remap {
pub fn remap_image(
image: impl GenericImage,
mappings: ColourMapping,
mappings: PaletteMap,
) -> anyhow::Result<OutputFormat> {
let mut output = new_image(image.width(), image.height());
for (x, y, pixel) in image.pixels() {
......
use crate::utils::TypedOutputFormat;
use clap::{Parser, ValueEnum};
use image::{imageops, GenericImage, Pixel};
use serde::{Deserialize, Serialize};
use crunch_cli::utils::TypedOutputFormat;
#[derive(Copy, Clone, Serialize, Deserialize, ValueEnum, Debug)]
pub enum RotateDegree {
......
use crate::utils::TypedOutputFormat;
use clap::Parser;
use image::imageops::FilterType;
use image::{imageops, GenericImage, Pixel};
use serde::{Deserialize, Serialize};
use crunch_cli::utils::TypedOutputFormat;
#[inline(always)]
fn one() -> f32 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment