Add missing docs for ImageLoader (#19499)
# Objective Yet another tiny step towards https://github.com/bevyengine/bevy/issues/3492. --------- Co-authored-by: SpecificProtagonist <vincentjunge@posteo.net>
This commit is contained in:
parent
f163649b48
commit
5279863c42
@ -81,19 +81,35 @@ impl ImageLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// How to determine an image's format when loading.
|
||||||
#[derive(Serialize, Deserialize, Default, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Default, Debug, Clone)]
|
||||||
pub enum ImageFormatSetting {
|
pub enum ImageFormatSetting {
|
||||||
|
/// Determine the image format from its file extension.
|
||||||
|
///
|
||||||
|
/// This is the default.
|
||||||
#[default]
|
#[default]
|
||||||
FromExtension,
|
FromExtension,
|
||||||
|
/// Declare the image format explicitly.
|
||||||
Format(ImageFormat),
|
Format(ImageFormat),
|
||||||
|
/// Guess the image format by looking for magic bytes at the
|
||||||
|
/// beginning of its data.
|
||||||
Guess,
|
Guess,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Settings for loading an [`Image`] using an [`ImageLoader`].
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct ImageLoaderSettings {
|
pub struct ImageLoaderSettings {
|
||||||
|
/// How to determine the image's format.
|
||||||
pub format: ImageFormatSetting,
|
pub format: ImageFormatSetting,
|
||||||
|
/// Specifies whether image data is linear
|
||||||
|
/// or in sRGB space when this is not determined by
|
||||||
|
/// the image format.
|
||||||
pub is_srgb: bool,
|
pub is_srgb: bool,
|
||||||
|
/// [`ImageSampler`] to use when rendering - this does
|
||||||
|
/// not affect the loading of the image data.
|
||||||
pub sampler: ImageSampler,
|
pub sampler: ImageSampler,
|
||||||
|
/// Where the asset will be used - see the docs on
|
||||||
|
/// [`RenderAssetUsages`] for details.
|
||||||
pub asset_usage: RenderAssetUsages,
|
pub asset_usage: RenderAssetUsages,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,11 +124,14 @@ impl Default for ImageLoaderSettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An error when loading an image using [`ImageLoader`].
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum ImageLoaderError {
|
pub enum ImageLoaderError {
|
||||||
#[error("Could load shader: {0}")]
|
/// An error occurred while trying to load the image bytes.
|
||||||
|
#[error("Failed to load image bytes: {0}")]
|
||||||
Io(#[from] std::io::Error),
|
Io(#[from] std::io::Error),
|
||||||
|
/// An error occurred while trying to decode the image bytes.
|
||||||
#[error("Could not load texture file: {0}")]
|
#[error("Could not load texture file: {0}")]
|
||||||
FileTexture(#[from] FileTextureError),
|
FileTexture(#[from] FileTextureError),
|
||||||
}
|
}
|
||||||
@ -170,7 +189,7 @@ impl AssetLoader for ImageLoader {
|
|||||||
|
|
||||||
/// An error that occurs when loading a texture from a file.
|
/// An error that occurs when loading a texture from a file.
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
#[error("Error reading image file {path}: {error}, this is an error in `bevy_render`.")]
|
#[error("Error reading image file {path}: {error}.")]
|
||||||
pub struct FileTextureError {
|
pub struct FileTextureError {
|
||||||
error: TextureError,
|
error: TextureError,
|
||||||
path: String,
|
path: String,
|
||||||
|
Loading…
Reference in New Issue
Block a user