Skip to content

Commit

Permalink
Fix Image convert docs
Browse files Browse the repository at this point in the history
  • Loading branch information
micron-mushroom committed Aug 2, 2022
1 parent 8e2d7f7 commit 49bfbd6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions crates/bevy_render/src/texture/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,14 @@ impl Image {
});
}

/// Convert a texture from a format to another
/// Only a few formats are supported as input and output:
/// Convert a texture from a format to another. Only a few formats are
/// supported as input and output:
/// - `TextureFormat::R8Unorm`
/// - `TextureFormat::Rg8Unorm`
/// - `TextureFormat::Rgba8UnormSrgb`
///
/// To get [`Image`] as a [`image::DynamicImage`] see:
/// [`Image::try_into_dynamic`].
pub fn convert(&self, new_format: TextureFormat) -> Option<Self> {
self.clone()
.try_into_dynamic()
Expand Down
12 changes: 8 additions & 4 deletions crates/bevy_render/src/texture/image_texture_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,14 @@ impl Image {
)
}

/// Converts an [`Image`] to a [`DynamicImage`]. Usefull for editing the
/// contents of an Image. Not all [`TextureFormat`] are covered, therefore
/// it will return `None` if the format is unsupported. The supported
/// formats are the same as those listed for `Image::convert`.
/// Convert a [`Image`] to a [`DynamicImage`]. Usefull for editing image
/// data. Not all [`TextureFormat`] are covered, therefore it will return an
/// error if the format is unsupported. Supported formats are:
/// - `TextureFormat::R8Unorm`
/// - `TextureFormat::Rg8Unorm`
/// - `TextureFormat::Rgba8UnormSrgb`
///
/// To convert [`Image`] to a different format see: [`Image::convert`].
pub fn try_into_dynamic(self) -> anyhow::Result<DynamicImage> {
match self.texture_descriptor.format {
TextureFormat::R8Unorm => ImageBuffer::from_raw(
Expand Down

0 comments on commit 49bfbd6

Please sign in to comment.