#image-processing #dds #image #directx #api-bindings

directxtex

Unofficial Rust bindings for Microsoft's DirectXTex library

5 stable releases

1.3.0 Jan 8, 2025
1.2.0 Jan 4, 2025
1.1.1 Dec 23, 2024
1.1.0 Dec 13, 2024
1.0.0 Jan 23, 2024

#171 in Images

Download history 8/week @ 2024-09-25 2/week @ 2024-10-02 4/week @ 2024-10-09 2/week @ 2024-10-16 8/week @ 2024-10-30 6/week @ 2024-11-06 3/week @ 2024-11-20 12/week @ 2024-11-27 57/week @ 2024-12-04 198/week @ 2024-12-11 170/week @ 2024-12-18 93/week @ 2024-12-25 204/week @ 2025-01-01 200/week @ 2025-01-08

680 downloads per month
Used in 2 crates

MIT license

1.5MB
31K SLoC

C++ 28K SLoC // 0.1% comments Rust 3K SLoC // 0.0% comments

DirectXTex Rust Bindings

These are unofficial Rust bindings for the DirectXTex texture processing library. A C++17 compliant compiler is required to build this library, and it is verified to work on Windows, Linux, and MacOS. The docs contain a migration table that describes the equivalency between the original C++ API and its Rust bindings. Please see DirectXTex's README for more info.

The stable release docs are available at: https://docs.rs/directxtex/latest/directxtex/

Changelogs are available at: https://github.com/Ryan-rsm-McKenzie/directxtex-rs/releases


lib.rs:

Migration Table

C++ Rust
IsValid DXGI_FORMAT::is_valid
IsCompressed DXGI_FORMAT::is_compressed
IsPacked DXGI_FORMAT::is_packed
IsVideo DXGI_FORMAT::is_video
IsPlanar DXGI_FORMAT::is_planar
IsPalettized DXGI_FORMAT::is_palettized
IsDepthStencil DXGI_FORMAT::is_depth_stencil
IsSRGB DXGI_FORMAT::is_srgb
IsBGR DXGI_FORMAT::is_bgr
IsTypeless DXGI_FORMAT::is_typeless
HasAlpha DXGI_FORMAT::has_alpha
BitsPerPixel DXGI_FORMAT::bits_per_pixel
BitsPerColor DXGI_FORMAT::bits_per_color
FORMAT_TYPE FORMAT_TYPE
FormatDataType DXGI_FORMAT::format_data_type
CP_FLAGS CP_FLAGS
ComputePitch DXGI_FORMAT::compute_pitch
ComputeScanlines DXGI_FORMAT::compute_scanlines
MakeSRGB DXGI_FORMAT::make_srgb
MakeLinear DXGI_FORMAT::make_linear
MakeTypeless DXGI_FORMAT::make_typeless
MakeTypelessUNORM DXGI_FORMAT::make_typeless_unorm
MakeTypelessFLOAT DXGI_FORMAT::make_typeless_float
TEX_DIMENSION TEX_DIMENSION
TEX_MISC_FLAG TEX_MISC_FLAG
TEX_MISC_FLAG2 TEX_MISC_FLAG2
TEX_ALPHA_MODE TEX_ALPHA_MODE
TexMetadata TexMetadata
TexMetadata::ComputeIndex TexMetadata::compute_index
TexMetadata::IsCubemap TexMetadata::is_cubemap
TexMetadata::IsPMAlpha TexMetadata::is_pm_alpha
TexMetadata::SetAlphaMode TexMetadata::set_alpha_mode
TexMetadata::GetAlphaMode TexMetadata::get_alpha_mode
TexMetadata::IsVolumemap TexMetadata::is_volumemap
DDSMetaData DDSMetaData
DDSMetaData::IsDX10 DDSMetaData::is_dx10
DDS_FLAGS DDS_FLAGS
TGA_FLAGS TGA_FLAGS
GetMetadataFromDDSMemoryEx TexMetadata::from_dds
GetMetadataFromHDRMemory TexMetadata::from_hdr
GetMetadataFromTGAMemory TexMetadata::from_tga
Image Image
ScratchImage ScratchImage
ScratchImage::Initialize ScratchImage::initialize
ScratchImage::Initialize1D ScratchImage::initialize_1d
ScratchImage::Initialize2D ScratchImage::initialize_2d
ScratchImage::Initialize3D ScratchImage::initialize_3d
ScratchImage::InitializeCube ScratchImage::initialize_cube
ScratchImage::InitializeFromImage ScratchImage::initialize_from_image
ScratchImage::InitializeArrayFromImages ScratchImage::initialize_array_from_images
ScratchImage::InitializeCubeFromImages ScratchImage::initialize_cube_from_images
ScratchImage::Initialize3DFromImages ScratchImage::initialize_3d_from_images
ScratchImage::Release ScratchImage::release
ScratchImage::OverrideFormat ScratchImage::override_format
ScratchImage::GetMetadata ScratchImage::metadata
ScratchImage::GetImage ScratchImage::image
ScratchImage::GetImages
ScratchImage::GetImageCount
ScratchImage::images
ScratchImage::GetPixels
ScratchImage::GetPixelsSize
ScratchImage::pixels
ScratchImage::pixels_mut
ScratchImage::IsAlphaAllOpaque ScratchImage::is_alpha_all_opaque
Blob Blob
Blob::Initialize Blob::initialize
Blob::Release Blob::release
Blob::GetBufferPointer
Blob::GetBufferSize
Blob::buffer
Blob::buffer_mut
Blob::Resize Blob::resize
Blob::Trim Blob::trim
LoadFromDDSMemoryEx ScratchImage::load_dds
SaveToDDSMemory save_dds
ScratchImage::save_dds
LoadFromHDRMemory ScratchImage::load_hdr
SaveToHDRMemory Image::save_hdr
LoadFromTGAMemory ScratchImage::load_tga
SaveToTGAMemory Image::save_tga
TEX_FILTER_FLAGS TEX_FILTER_FLAGS
TEX_FILTER_DITHER_MASK TEX_FILTER_DITHER_MASK
TEX_FILTER_MODE_MASK TEX_FILTER_MODE_MASK
TEX_FILTER_SRGB_MASK TEX_FILTER_SRGB_MASK
Resize resize
ScratchImage::resize
Image::resize
TEX_THRESHOLD_DEFAULT TEX_THRESHOLD_DEFAULT
Convert convert
ScratchImage::convert
Image::convert
ConvertToSinglePlane convert_to_single_plane
ScratchImage::convert_to_single_plane
Image::convert_to_single_plane
GenerateMipMaps generate_mip_maps
ScratchImage::generate_mip_maps
Image::generate_mip_maps
GenerateMipMaps3D generate_mip_maps_3d
ScratchImage::generate_mip_maps_3d
ScaleMipMapsAlphaForCoverage scale_mip_maps_alpha_for_coverage
ScratchImage::scale_mip_maps_alpha_for_coverage
TEX_PMALPHA_FLAGS TEX_PMALPHA_FLAGS
PremultiplyAlpha premultiply_alpha
ScratchImage::premultiply_alpha
Image::premultiply_alpha
TEX_COMPRESS_FLAGS TEX_COMPRESS_FLAGS
TEX_ALPHA_WEIGHT_DEFAULT TEX_ALPHA_WEIGHT_DEFAULT
Compress compress
ScratchImage::compress
Image::compress
Decompress decompress
ScratchImage::decompress
Image::decompress
CNMAP_FLAGS CNMAP_FLAGS
ComputeNormalMap compute_normal_map
ScratchImage::compute_normal_map
Image::compute_normal_map
Rect Rect
CopyRectangle Image::copy_rectangle
CMSE_FLAGS CMSE_FLAGS
ComputeMSE Image::compute_mse
EncodeDDSHeader TexMetadata::encode_dds_header

Dependencies

~5MB
~63K SLoC