11//! Loading and rendering textures. Also render textures, per-pixel image manipulations.
22
3- use crate :: {
4- color :: Color , file :: load_file , get_context , get_quad_context , math :: Rect ,
5- text :: atlas :: SpriteKey , Error ,
6- } ;
3+ use crate :: { color :: Color , get_context , get_quad_context , math :: Rect , text :: atlas :: SpriteKey } ;
4+
5+ # [ cfg ( feature = "image-crate" ) ]
6+ use crate :: { file :: load_file , Error } ;
77
88pub use crate :: quad_gl:: FilterMode ;
99use crate :: quad_gl:: { DrawMode , Vertex } ;
@@ -94,6 +94,7 @@ impl Image {
9494 }
9595 }
9696
97+ #[ cfg( feature = "image-crate" ) ]
9798 /// Creates an Image from a slice of bytes that contains an encoded image.
9899 ///
99100 /// If `format` is None, it will make an educated guess on the
@@ -303,6 +304,7 @@ impl Image {
303304 }
304305 }
305306
307+ #[ cfg( feature = "image-crate" ) ]
306308 /// Saves this image as a PNG file.
307309 /// This method is not supported on web and will panic.
308310 pub fn export_png ( & self , path : & str ) {
@@ -327,13 +329,15 @@ impl Image {
327329 }
328330}
329331
332+ #[ cfg( feature = "image-crate" ) ]
330333/// Loads an [Image] from a file into CPU memory.
331334pub async fn load_image ( path : & str ) -> Result < Image , Error > {
332335 let bytes = load_file ( path) . await ?;
333336
334337 Image :: from_file_with_format ( & bytes, None )
335338}
336339
340+ #[ cfg( feature = "image-crate" ) ]
337341/// Loads a [Texture2D] from a file into GPU memory.
338342pub async fn load_texture ( path : & str ) -> Result < Texture2D , Error > {
339343 let bytes = load_file ( path) . await ?;
@@ -671,6 +675,7 @@ impl Texture2D {
671675 Texture2D :: unmanaged ( ctx. gl . white_texture )
672676 }
673677
678+ #[ cfg( feature = "image-crate" ) ]
674679 /// Creates a Texture2D from a slice of bytes that contains an encoded image.
675680 ///
676681 /// If `format` is None, it will make an educated guess on the
0 commit comments