mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix deprecated function use
This commit is contained in:
parent
ca2ef3e813
commit
f36e74e383
@ -175,9 +175,10 @@ impl TakeScreenshot {
|
||||
let image = match self.tex_format {
|
||||
wgpu::TextureFormat::Bgra8UnormSrgb => {
|
||||
let (pixels, rest) = pixel_bytes.as_chunks_mut();
|
||||
// Always valid because each pixel should use four bytes.
|
||||
assert!(rest.is_empty());
|
||||
|
||||
assert!(
|
||||
rest.is_empty(),
|
||||
"Always valid because each pixel uses four bytes"
|
||||
);
|
||||
// Swap blue and red components to get a RGBA texture.
|
||||
for [b, _g, r, _a] in pixels {
|
||||
std::mem::swap(b, r);
|
||||
|
@ -14,7 +14,7 @@ use common_net::msg::compression::{
|
||||
WidePacking,
|
||||
};
|
||||
use hashbrown::HashMap;
|
||||
use image::ImageBuffer;
|
||||
use image::{ImageBuffer, ImageEncoder};
|
||||
use num_traits::cast::FromPrimitive;
|
||||
use rayon::ThreadPoolBuilder;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -200,7 +200,7 @@ impl VoxelImageEncoding for PngEncoding {
|
||||
CompressionType::Rle,
|
||||
FilterType::Up,
|
||||
);
|
||||
png.encode(
|
||||
png.write_image(
|
||||
&*ws.as_raw(),
|
||||
ws.width(),
|
||||
ws.height(),
|
||||
@ -300,7 +300,7 @@ impl VoxelImageEncoding for MixedEncoding {
|
||||
CompressionType::Rle,
|
||||
FilterType::Up,
|
||||
);
|
||||
png.encode(&*x.as_raw(), x.width(), x.height(), image::ColorType::L8)
|
||||
png.write_image(&*x.as_raw(), x.width(), x.height(), image::ColorType::L8)
|
||||
.ok()?;
|
||||
indices[i] = buf.len();
|
||||
Some(())
|
||||
@ -406,7 +406,7 @@ impl VoxelImageEncoding for MixedEncodingSparseSprites {
|
||||
CompressionType::Fast,
|
||||
FilterType::Up,
|
||||
);
|
||||
png.encode(
|
||||
png.write_image(
|
||||
&*ws.0.as_raw(),
|
||||
ws.0.width(),
|
||||
ws.0.height(),
|
||||
@ -471,7 +471,7 @@ impl VoxelImageEncoding for MixedEncodingDenseSprites {
|
||||
CompressionType::Fast,
|
||||
FilterType::Up,
|
||||
);
|
||||
png.encode(&*x.as_raw(), x.width(), x.height(), image::ColorType::L8)
|
||||
png.write_image(&*x.as_raw(), x.width(), x.height(), image::ColorType::L8)
|
||||
.ok()?;
|
||||
indices[i] = buf.len();
|
||||
Some(())
|
||||
@ -637,7 +637,7 @@ impl<'a, NN: NearestNeighbor, const N: u32> VoxelImageEncoding for PaletteEncodi
|
||||
CompressionType::Rle,
|
||||
FilterType::Up,
|
||||
);
|
||||
png.encode(&*x.as_raw(), x.width(), x.height(), image::ColorType::L8)
|
||||
png.write_image(&*x.as_raw(), x.width(), x.height(), image::ColorType::L8)
|
||||
.ok()?;
|
||||
indices[i] = buf.len();
|
||||
Some(())
|
||||
|
@ -1,6 +1,6 @@
|
||||
use image::{
|
||||
codecs::png::{CompressionType, FilterType, PngEncoder},
|
||||
ImageBuffer,
|
||||
ImageBuffer, ImageEncoder,
|
||||
};
|
||||
use rayon::ThreadPoolBuilder;
|
||||
use std::{fs::File, io::Write};
|
||||
@ -83,7 +83,7 @@ fn image_from_function<F: FnMut(u32, u32) -> [u8; 3]>(
|
||||
let mut heightmap_png = Vec::new();
|
||||
let png =
|
||||
PngEncoder::new_with_quality(&mut heightmap_png, CompressionType::Best, FilterType::Paeth);
|
||||
png.encode(
|
||||
png.write_image(
|
||||
&*heightmap.as_raw(),
|
||||
heightmap.width(),
|
||||
heightmap.height(),
|
||||
|
Loading…
Reference in New Issue
Block a user