@@ -81,19 +81,35 @@ impl ImageLoader {
81
81
}
82
82
}
83
83
84
+ /// How to determine an image's format when loading.
84
85
#[ derive( Serialize , Deserialize , Default , Debug , Clone ) ]
85
86
pub enum ImageFormatSetting {
87
+ /// Determine the image format from its file extension.
88
+ ///
89
+ /// This is the default.
86
90
#[ default]
87
91
FromExtension ,
92
+ /// Declare the image format explicitly.
88
93
Format ( ImageFormat ) ,
94
+ /// Guess the image format by looking for magic bytes at the
95
+ /// beginning of its data.
89
96
Guess ,
90
97
}
91
98
99
+ /// Settings for loading an [`Image`] using an [`ImageLoader`].
92
100
#[ derive( Serialize , Deserialize , Debug , Clone ) ]
93
101
pub struct ImageLoaderSettings {
102
+ /// How to determine the image's format.
94
103
pub format : ImageFormatSetting ,
104
+ /// Specifies whether image data is linear
105
+ /// or in sRGB space when this is not determined by
106
+ /// the image format.
95
107
pub is_srgb : bool ,
108
+ /// [`ImageSampler`] to use when rendering - this does
109
+ /// not affect the loading of the image data.
96
110
pub sampler : ImageSampler ,
111
+ /// Where the asset will be used - see the docs on
112
+ /// [`RenderAssetUsages`] for details.
97
113
pub asset_usage : RenderAssetUsages ,
98
114
}
99
115
@@ -108,11 +124,14 @@ impl Default for ImageLoaderSettings {
108
124
}
109
125
}
110
126
127
+ /// An error when loading an image using [`ImageLoader`].
111
128
#[ non_exhaustive]
112
129
#[ derive( Debug , Error ) ]
113
130
pub enum ImageLoaderError {
114
- #[ error( "Could load shader: {0}" ) ]
131
+ /// An error occurred while trying to load the image bytes.
132
+ #[ error( "Failed to load image bytes: {0}" ) ]
115
133
Io ( #[ from] std:: io:: Error ) ,
134
+ /// An error occurred while trying to decode the image bytes.
116
135
#[ error( "Could not load texture file: {0}" ) ]
117
136
FileTexture ( #[ from] FileTextureError ) ,
118
137
}
@@ -170,7 +189,7 @@ impl AssetLoader for ImageLoader {
170
189
171
190
/// An error that occurs when loading a texture from a file.
172
191
#[ derive( Error , Debug ) ]
173
- #[ error( "Error reading image file {path}: {error}, this is an error in `bevy_render` ." ) ]
192
+ #[ error( "Error reading image file {path}: {error}." ) ]
174
193
pub struct FileTextureError {
175
194
error : TextureError ,
176
195
path : String ,
0 commit comments