We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code here
use std::io::BufWriter; use std::num::NonZeroU32; use image::codecs::png::PngEncoder; use image::io::Reader as ImageReader; use image::{ColorType, ImageEncoder}; use fast_image_resize as fir; fn main() { not_work(); // output: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] work(); // output: [255, 196, 181, 255, 196, 181, 255, 198, 181, 255] } fn work() { let img = ImageReader::open("/dev/shm/0/1.png") .unwrap() .decode() .unwrap(); let width = NonZeroU32::new(img.width()).unwrap(); let height = NonZeroU32::new(img.height()).unwrap(); let src_image = fir::Image::from_vec_u8( width, height, img.to_rgb8().into_raw(), fir::PixelType::U8x3, ) .unwrap(); let fix_width = NonZeroU32::new(img.width() * 2).unwrap(); let fix_height = NonZeroU32::new(img.height() * 2).unwrap(); let dst_width = fix_width; // fix here let dst_height = fix_height; let mut dst_image = fir::Image::new(dst_width, dst_height, src_image.pixel_type()); let mut dst_view = dst_image.view_mut(); let mut resizer = fir::Resizer::new(fir::ResizeAlg::Convolution(fir::FilterType::Box)); resizer.resize(&src_image.view(), &mut dst_view).unwrap(); eprintln!("{:?}", &dst_image.buffer()[0..10]); } fn not_work() { let img = ImageReader::open("/dev/shm/0/1.png") .unwrap() .decode() .unwrap(); let width = NonZeroU32::new(img.width()).unwrap(); let height = NonZeroU32::new(img.height()).unwrap(); let src_image = fir::Image::from_vec_u8( width, height, img.to_rgb8().into_raw(), fir::PixelType::U8x3, ) .unwrap(); let dst_width = width; // bug here let dst_height = height; let mut dst_image = fir::Image::new(dst_width, dst_height, src_image.pixel_type()); let mut dst_view = dst_image.view_mut(); let mut resizer = fir::Resizer::new(fir::ResizeAlg::Convolution(fir::FilterType::Box)); resizer.resize(&src_image.view(), &mut dst_view).unwrap(); eprintln!("{:?}", &dst_image.buffer()[0..10]); }
The text was updated successfully, but these errors were encountered:
Fixed resizing when the destination image has the same dimensions as …
6483439
…the source image (#9).
Thank you. Has fixed in release 0.9.7
Sorry, something went wrong.
Cykooz
No branches or pull requests
Code here
The text was updated successfully, but these errors were encountered: