bevyengine/bevy
bevy_image
Image and texture asset types, plus loaders for the standard formats. The bridge between bytes on disk and wgpu::Texture on the GPU.
Purpose
bevy_image provides:
Image— the asset that wraps texture data and metadata.- Format loaders — PNG, JPEG, BMP, GIF, TGA, TIFF, WebP, EXR, HDR, KTX2, BasisUniversal — each gated by a cargo feature.
- Sampler descriptors — how the texture is sampled (nearest/linear, repeat/clamp, anisotropy).
- Compressed-format support — BCn, ASTC, ETC2 via KTX2 + Basis.
The crate is GPU-format-aware: an Image knows its TextureFormat, mip levels, and intended sampler.
Directory layout
crates/bevy_image/src/
├── lib.rs # ImagePlugin, Image, ImageSampler
├── image.rs # Image asset
├── image_loader.rs # Generic loader (PNG, JPEG, etc.)
├── ktx2.rs # KTX2 format
├── basis.rs # Basis Universal
├── dds.rs # DDS
├── exr_texture_loader.rs
├── hdr_texture_loader.rs
├── prelude.rs
└── …Key abstractions
| Type | File | Description |
|---|---|---|
Image |
crates/bevy_image/src/image.rs |
Asset; texture data + metadata. |
ImageSampler |
crates/bevy_image/src/image.rs |
Sampler config. |
ImagePlugin |
crates/bevy_image/src/lib.rs |
Registers loaders, default sampler. |
ImageType, CompressedImageFormats |
crates/bevy_image/src/image.rs |
Format hints used during decoding. |
| Per-format loaders | crates/bevy_image/src/{ktx2,basis,dds,…}.rs |
One per compressed/HDR format. |
How it works
A loader reads bytes, decodes to either raw pixel data or a GPU-ready compressed format, and produces an Image asset. Renderers (bevy_pbr, bevy_sprite_render, bevy_ui_render) consume Handle<Image> and upload to the GPU on first use.
Image::new, Image::new_fill, and Image::from_dynamic are the common constructors when generating images programmatically (e.g. procedural textures, render-to-texture targets).
Integration points
- Depends on:
image(the crate),wgpu-types,ktx2,basis-universal,bevy_asset,bevy_color,bevy_math,bevy_reflect. - Depended on by: Every renderer crate,
bevy_pbr,bevy_text(font atlas),bevy_gltf, …
Entry points for modification
- New format: add a loader file modeled after
ktx2.rsand gate behind a cargo feature. - Default sampler change:
ImagePlugin::default_sampleris the resource consumers read. - Color-space handling: check
Image::texture_descriptor.formatand theis_srgbplumbing.
See also
bevy_asset— asset infrastructure.bevy_render— uploadsImageto GPU.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.