Skip to content

Commit

Permalink
Use configured sampler for all image types in from_bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
cart committed Oct 25, 2023
1 parent 821d8ef commit ac879b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions crates/bevy_render/src/texture/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,16 +631,16 @@ impl Image {
// needs to be added, so the image data needs to be converted in those
// cases.

match format {
let mut image = match format {
#[cfg(feature = "basis-universal")]
ImageFormat::Basis => {
basis_buffer_to_image(buffer, supported_compressed_formats, is_srgb)
basis_buffer_to_image(buffer, supported_compressed_formats, is_srgb)?
}
#[cfg(feature = "dds")]
ImageFormat::Dds => dds_buffer_to_image(buffer, supported_compressed_formats, is_srgb),
ImageFormat::Dds => dds_buffer_to_image(buffer, supported_compressed_formats, is_srgb)?,
#[cfg(feature = "ktx2")]
ImageFormat::Ktx2 => {
ktx2_buffer_to_image(buffer, supported_compressed_formats, is_srgb)
ktx2_buffer_to_image(buffer, supported_compressed_formats, is_srgb)?
}
_ => {
let image_crate_format = format
Expand All @@ -650,11 +650,11 @@ impl Image {
reader.set_format(image_crate_format);
reader.no_limits();
let dyn_img = reader.decode()?;
let mut img = Self::from_dynamic(dyn_img, is_srgb);
img.sampler = image_sampler;
Ok(img)
Self::from_dynamic(dyn_img, is_srgb)
}
}
};
image.sampler = image_sampler;
Ok(image)
}

/// Whether the texture format is compressed or uncompressed
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_render/src/texture/image_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ pub(crate) const IMG_FILE_EXTENSIONS: &[&str] = &[
"ppm",
];

#[derive(Serialize, Deserialize, Default)]
#[derive(Serialize, Deserialize, Default, Debug)]
pub enum ImageFormatSetting {
#[default]
FromExtension,
Format(ImageFormat),
}

#[derive(Serialize, Deserialize)]
#[derive(Serialize, Deserialize, Debug)]
pub struct ImageLoaderSettings {
pub format: ImageFormatSetting,
pub is_srgb: bool,
Expand Down

0 comments on commit ac879b2

Please sign in to comment.