scanmountgoat / image_dds Goto Github PK
View Code? Open in Web Editor NEWConvert images to and from compressed DDS formats
License: MIT License
Convert images to and from compressed DDS formats
License: MIT License
This will require defining separate conversions to and from f32 data since some formats like BC6 use half precision floating point. Most logic can be shared with rgba8 conversions.
Decoding already handles this case. This will require padding the rgba8 data horizontally and vertically to have an integral dimension in blocks.
This can be done as combined tests that encode and then decode simple solid colors to avoid any block compression artifacts. This mostly checks that type conversions are handled properly.
This is really only relevant for applications wishing to use DDS as an interchange format for both compressed and uncompressed data.
Encoding currently requires precompiled kernels and may not be available on all targets. Decoding compiles C code and may not be required for projects just wanting to convert DDS files to and from surfaces.
Defualt format is ok, but when i try Rgba32Float format, get panic.
_ => image_dds::dds_from_imagef32(
&image,
image_dds::ImageFormat::Rgba32Float,
image_dds::Quality::Fast,
image_dds::Mipmaps::GeneratedAutomatic,
)
.unwrap(),
thread 'main' panicked at C:\Users\zhouhang\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\bytemuck-1.15.0\src\allocation.rs:200:44:
called `Result::unwrap()` on an `Err` value: AlignmentMismatch
stack backtrace:
0: 0x7ff7f6531e92 - std::sys_common::backtrace::_print::impl$0::fmt
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\sys_common\backtrace.rs:44
1: 0x7ff7f6547e3d - core::fmt::rt::Argument::fmt
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\core\src\fmt\rt.rs:142
2: 0x7ff7f6547e3d - core::fmt::write
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\core\src\fmt\mod.rs:1120
3: 0x7ff7f652f7e1 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\io\mod.rs:1846
4: 0x7ff7f6531cba - std::sys_common::backtrace::_print
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\sys_common\backtrace.rs:47
5: 0x7ff7f6531cba - std::sys_common::backtrace::print
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\sys_common\backtrace.rs:34
6: 0x7ff7f6533e69 - std::panicking::default_hook::closure$1
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panicking.rs:272
7: 0x7ff7f6533b25 - std::panicking::default_hook
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panicking.rs:292
8: 0x7ff7f6534384 - std::panicking::rust_panic_with_hook
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panicking.rs:781
9: 0x7ff7f6534259 - std::panicking::begin_panic_handler::closure$0
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panicking.rs:659
10: 0x7ff7f6532539 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\sys_common\backtrace.rs:171
11: 0x7ff7f6533f26 - std::panicking::begin_panic_handler
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panicking.rs:647
12: 0x7ff7f65546e7 - core::panicking::panic_fmt
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\core\src\panicking.rs:72
13: 0x7ff7f6554d23 - core::result::unwrap_failed
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\core\src\result.rs:1649
14: 0x7ff7f6021035 - enum2$<core::result::Result<alloc::vec::Vec<u8,alloc::alloc::Global>,bytemuck::PodCastError> >::unwrap
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\core\src\result.rs:1073
15: 0x7ff7f6021035 - bytemuck::allocation::cast_vec<half::binary16::f16,u8>
at C:\Users\zhouhang\.cargo\registry\src\rsproxy.cn-0dccff568467c15b\bytemuck-1.15.0\src\allocation.rs:200
16: 0x7ff7f6018790 - core::ops::function::FnOnce::call_once<alloc::vec::Vec<u8,alloc::alloc::Global> (*)(alloc::vec::Vec<half::binary16::f16,alloc::alloc::Global>),tuple$<alloc::vec::Vec<half::binary16::f16,alloc::alloc::Global> > >
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\core\src\ops\function.rs:250
17: 0x7ff7f601da40 - enum2$<core::result::Result<alloc::vec::Vec<half::binary16::f16,alloc::alloc::Global>,enum2$<image_dds::error::SurfaceError> > >::map<alloc::vec::Vec<half::binary16::f16,alloc::alloc::Global>,enum2$<image_dds::error::SurfaceError>,alloc::vec::Vec<u8,alloc
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\core\src\result.rs:746
18: 0x7ff7f60240c7 - image_dds::encode::impl$7::encode
at D:\image_dds\image_dds\src\encode.rs:408
19: 0x7ff7f60202f9 - image_dds::encode::MipData<f32>::encode<f32>
at D:\image_dds\image_dds\src\encode.rs:173
20: 0x7ff7f601fbd9 - image_dds::encode::encode_mipmaps_rgba<image_dds::surface::SurfaceRgba32Float<ref$<slice2$<f32> > >,f32>
at D:\image_dds\image_dds\src\encode.rs:115
21: 0x7ff7f601f8c9 - image_dds::encode::encode_surface<image_dds::surface::SurfaceRgba32Float<ref$<slice2$<f32> > >,f32>
at D:\image_dds\image_dds\src\encode.rs:72
22: 0x7ff7f60182dc - image_dds::surface::SurfaceRgba32Float<ref$<slice2$<f32> > >::encode<ref$<slice2$<f32> > >
at D:\image_dds\image_dds\src\encode.rs:41
23: 0x7ff7f601756c - image_dds::dds::dds_from_imagef32
at D:\image_dds\image_dds\src\dds.rs:50
24: 0x7ff7f6014dbf - img2ddsf32::main
at D:\image_dds\image_dds\examples\img2ddsf32.rs:33
25: 0x7ff7f6015c2b - core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\core\src\ops\function.rs:250
26: 0x7ff7f60125fe - core::hint::black_box
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\core\src\hint.rs:334
27: 0x7ff7f60125fe - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\std\src\sys_common\backtrace.rs:155
28: 0x7ff7f6015b31 - std::rt::lang_start::closure$0<tuple$<> >
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\std\src\rt.rs:166
29: 0x7ff7f652ade2 - std::rt::lang_start_internal::closure$2
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\rt.rs:148
30: 0x7ff7f652ade2 - std::panicking::try::do_call
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panicking.rs:554
31: 0x7ff7f652ade2 - std::panicking::try
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panicking.rs:518
32: 0x7ff7f652ade2 - std::panic::catch_unwind
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panic.rs:142
33: 0x7ff7f652ade2 - std::rt::lang_start_internal
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\rt.rs:148
34: 0x7ff7f6015b0a - std::rt::lang_start<tuple$<> >
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\std\src\rt.rs:165
35: 0x7ff7f6015759 - main
36: 0x7ff7f65528d8 - invoke_main
at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
37: 0x7ff7f65528d8 - __scrt_common_main_seh
at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
38: 0x7ffe300a257d - BaseThreadInitThunk
39: 0x7ffe3180aa48 - RtlUserThreadStart
bcdec is one of the faster decoding libraries, so this is worth looking into. This shouldn't have any impact on the public API.
This should take a horizontal arrangement of slices and encode with appropriate handling of mipmaps.
This is necessary for some game formats. This will needf32
support from #1 to work properly with images.
This can probably just return an error if there isn't enough data in the surface.
This should support common cube map representations like multiple images, cross, etc with mipmap support.
Similar to #11, this will make compilation easier for some use cases. This will be more involved than decoding since intel_tex_rs uses the intel ispc compiler and is fairly complex. It may be better to make bindings to a smaller library first like https://github.com/elasota/ConvectionKernels and fuzz the Rust port against the original C++ code. It's also worth investigating the potential performance loss since intel_tex_rs makes heavy use of SIMD.
While unlikely to improve performance, this will make the integration easier due to less required safety checks. This will also make the code easier to build on more targets due to not requiring the compilation and linking of C code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.