-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
212 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "rmg" | ||
version = "0.2.3" | ||
version = "0.2.4" | ||
edition = "2021" | ||
authors = ["RSUU <[email protected]>"] | ||
description = "Rust: Tiny Manga/Image Viewer" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,17 @@ | ||
#![allow(deprecated)] | ||
|
||
use criterion::{criterion_group, Criterion}; | ||
use rmg::color::rgba::TransRgba; | ||
|
||
pub static mut RES_BUFFER: Vec<u32> = Vec::new(); | ||
pub static mut COLOR_BUFFER: Vec<u8> = Vec::new(); | ||
|
||
pub fn c_color(c: &mut Criterion) { | ||
c.bench_function("with_step: u8 to rgba", |b| b.iter(with_step)); | ||
c.bench_function("with_chunks: u8 to rgba", |b| b.iter(with_chunks)); | ||
} | ||
|
||
#[inline] | ||
fn with_step() { | ||
unsafe { | ||
COLOR_BUFFER = vec![0; 40]; | ||
|
||
for f in (4..COLOR_BUFFER.len()).step_by(4) { | ||
RES_BUFFER.push(TransRgba::rgba_to_u32( | ||
&COLOR_BUFFER[f - 4..f].try_into().unwrap(), | ||
)); | ||
} | ||
} | ||
} | ||
fn with_step() {} | ||
|
||
#[inline] | ||
fn with_chunks() { | ||
unsafe { | ||
COLOR_BUFFER = vec![0; 40]; | ||
|
||
for f in COLOR_BUFFER.as_slice().chunks(4) { | ||
RES_BUFFER.push(TransRgba::rgba_to_u32(f.try_into().unwrap())); | ||
} | ||
} | ||
} | ||
fn with_chunks() {} | ||
|
||
criterion_group!(bench, c_color); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
use crate::{ | ||
img::size::Size, | ||
reader::view::Page, | ||
utils::err::{MyErr, Res}, | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
use gif; | ||
use log; | ||
use std::fs::File; | ||
|
||
|
||
use std::io::Read; | ||
use std::mem; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,37 @@ | ||
use resvg; | ||
use tiny_skia; | ||
use usvg; | ||
use usvg::{self, ScreenRect}; | ||
|
||
/* | ||
use crate::utils::err::Res; | ||
|
||
use super::size::Size; | ||
|
||
pub fn load_svg(bytes: &[u8]) -> Res<(Size<u32>, Vec<Vec<u8>>)> { | ||
// let (width, height) = (3000, 3000); | ||
let size = Size::new(2000, 2000); | ||
let opt = usvg::Options::default(); | ||
let svg_data = std::fs::read(&img_location)?; | ||
if let Ok(rtree) = usvg::Tree::from_data(&svg_data, &opt.to_ref()) { | ||
// let pixmap_size = rtree.svg_node().size.to_screen_size() | ||
let pixmap_size = rtree.size.to_screen_size(); | ||
// .scale_to(ScreenSize::new(width, height)?); | ||
|
||
if let Ok(rtree) = usvg::Tree::from_data(&bytes, &opt.to_ref()) { | ||
let pixmap_size = rtree | ||
.size | ||
.to_screen_size() | ||
.scale_to(usvg::ScreenSize::new(size.width, size.height).unwrap()); | ||
|
||
if let Some(mut pixmap) = tiny_skia::Pixmap::new(pixmap_size.width(), pixmap_size.height()) | ||
{ | ||
resvg::render( | ||
&rtree, | ||
usvg::FitTo::Original, | ||
usvg::FitTo::Height(size.height), | ||
//usvg::FitTo::Original, | ||
tiny_skia::Transform::identity(), | ||
pixmap.as_mut(), | ||
) | ||
.ok_or(anyhow!("Can't render SVG"))?; | ||
// resvg::render(&rtree, usvg::FitTo::Height(height), pixmap.as_mut())?; | ||
let buf: Option<RgbaImage> = image::ImageBuffer::from_raw( | ||
pixmap_size.width(), | ||
pixmap_size.height(), | ||
pixmap.data().to_vec(), | ||
); | ||
if let Some(valid_buf) = buf { | ||
col.add_still(valid_buf); | ||
} | ||
.unwrap(); | ||
|
||
return Ok((size, vec![pixmap.data().to_vec()])); | ||
} else { | ||
} | ||
} else { | ||
} | ||
} | ||
|
||
*/ | ||
Err(crate::utils::err::MyErr::Todo) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,7 @@ pub mod archive { | |
Tar, | ||
Zip, | ||
Dir, | ||
File, | ||
} | ||
|
||
pub mod dir; | ||
|
Oops, something went wrong.