From 49bfbd698635c64b87b15a91c32171b83dd85b3f Mon Sep 17 00:00:00 2001 From: micron-mushroom Date: Tue, 2 Aug 2022 17:09:02 +0200 Subject: [PATCH] Fix `Image` convert docs --- crates/bevy_render/src/texture/image.rs | 7 +++++-- .../src/texture/image_texture_conversion.rs | 12 ++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/crates/bevy_render/src/texture/image.rs b/crates/bevy_render/src/texture/image.rs index 23e26f680366e..e4f88d0eac4ef 100644 --- a/crates/bevy_render/src/texture/image.rs +++ b/crates/bevy_render/src/texture/image.rs @@ -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.clone() .try_into_dynamic() diff --git a/crates/bevy_render/src/texture/image_texture_conversion.rs b/crates/bevy_render/src/texture/image_texture_conversion.rs index f004f1744b13f..45ae5bbc22582 100644 --- a/crates/bevy_render/src/texture/image_texture_conversion.rs +++ b/crates/bevy_render/src/texture/image_texture_conversion.rs @@ -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 { match self.texture_descriptor.format { TextureFormat::R8Unorm => ImageBuffer::from_raw(