diff --git a/Cargo.lock b/Cargo.lock index efbc47b..84b5562 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,12 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - [[package]] name = "cfg-if" version = "1.0.0" @@ -16,76 +10,72 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "crossbeam-deque" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fca89a0e215bab21874660c67903c5f143333cab1da83d041c7ded6053774751" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.16" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d2fe95351b870527a5d09bf563ed3c97c0cffb87cf1c78a591bf48bb218d9aa" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "autocfg", - "cfg-if", "crossbeam-utils", - "memoffset", ] [[package]] name = "crossbeam-utils" -version = "0.8.17" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d96137f14f244c37f989d9fff8f95e6c18b918e71f36638f8c49112e4c78f" -dependencies = [ - "cfg-if", -] +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "jxl-bitstream" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32ae9d8f3dfbef298b8357a283fad85da9c59027229e28beafcfc9d2a810a398" +checksum = "23ace52f4e7df7cf39e3132da74184a9f2dcd375c01008c28bb5e0af668d3254" dependencies = [ "tracing", ] [[package]] name = "jxl-coding" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "851149f14415943e525e6259ddff212a1f507e0b12ee6f9fc0fa5266bea88891" +checksum = "720c19e732100891ced54ef3a565dda867cdcbb355fe388e218ff09fda738368" dependencies = [ "jxl-bitstream", + "tracing", ] [[package]] name = "jxl-color" -version = "0.4.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320b54db472711efc56c8b257207b91772277e926b21e686cb23d10daf2c7f8f" +checksum = "9ef54a5228a8f193c8d7aeb341aceffad7d8ddd2469ae8a483029a262d7b45f8" dependencies = [ "jxl-bitstream", "jxl-coding", "jxl-grid", + "jxl-threadpool", + "tracing", ] [[package]] name = "jxl-frame" -version = "0.6.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "694f9d1d3f6addabf74ad9ca664ef0e760e85a66558dc348d03137a7adda620c" +checksum = "fd5c39977033aaa7484dfb14a273c2bd5f4ebf38ba4f344d8d4d5ab33a723956" dependencies = [ "jxl-bitstream", "jxl-coding", @@ -99,15 +89,18 @@ dependencies = [ [[package]] name = "jxl-grid" -version = "0.2.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93164539f6339d98341835684b5c8458dafd9a5dfb2fdbd3c821ea00f58a86d" +checksum = "5b25b54442448752e9ccbd5e177da76e84b464054eddef792c44ceb11fc68aba" +dependencies = [ + "tracing", +] [[package]] name = "jxl-image" -version = "0.6.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c33911f1240386e4d0f874b313a4d27b68c5f67d4a7a418990b6605543c08a39" +checksum = "e286d078e21230db8c3c62769bab7f8696168d3718222d1c59b7fea9a87bc7c1" dependencies = [ "jxl-bitstream", "jxl-color", @@ -117,9 +110,9 @@ dependencies = [ [[package]] name = "jxl-modular" -version = "0.4.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3aa0fd75ed9e7101c1dcf7172ccac722705f6e75cc0b44721154765846a2d70" +checksum = "4274c241d7bf25216f87406d6d7c0f4826ba961eefaaf9a6a3982a235df64837" dependencies = [ "jxl-bitstream", "jxl-coding", @@ -130,9 +123,9 @@ dependencies = [ [[package]] name = "jxl-oxide" -version = "0.5.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e986fe957d42be34043ed5b089c34c35a182524509e6cfee87d86527f61f9623" +checksum = "31e0ad6f1defe2126f33bb24b4dfab84b7ea3dd6720af0399abb75ab4d20a7fb" dependencies = [ "jxl-bitstream", "jxl-color", @@ -146,9 +139,9 @@ dependencies = [ [[package]] name = "jxl-render" -version = "0.5.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b862f98f83049febe65feb40d75493638386721ff5dff4c6a5ad267035881bf" +checksum = "90809573df2958b1598601a93e76afc10009419e21948afbd78c74989eb7946d" dependencies = [ "jxl-bitstream", "jxl-coding", @@ -164,9 +157,9 @@ dependencies = [ [[package]] name = "jxl-threadpool" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcd3e9cf51745c0f4e86cd728c2725d62f0d1c8611a10307e96c2af6226db291" +checksum = "9d2860c68899a3c6266044fc26c6a0041e9f27145f58cc69b6eedc1b77f5ee13" dependencies = [ "rayon", "rayon-core", @@ -175,9 +168,9 @@ dependencies = [ [[package]] name = "jxl-vardct" -version = "0.4.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "027bacaccf80849dfa4513354c8c41e8e4e1a112efeb682f6b3e9aeb4b4db481" +checksum = "4853dae1aaec0e5a5acb0ff1b5e47263dcfcbd40aecf89bc71c34a50f158dfb9" dependencies = [ "jxl-bitstream", "jxl-coding", @@ -206,24 +199,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.151" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" - -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "once_cell" @@ -239,27 +223,27 @@ checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "proc-macro2" -version = "1.0.70" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] [[package]] name = "rayon" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" dependencies = [ "either", "rayon-core", @@ -267,9 +251,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.12.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ "crossbeam-deque", "crossbeam-utils", @@ -294,9 +278,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.109" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -363,20 +347,31 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.44.0" +version = "0.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e745dab35a0c4c77aa3ce42d595e13d2003d6902d6b08c9ef5fc326d08da12b" +checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" dependencies = [ + "windows-core", "windows-implement", "windows-interface", - "windows-targets", + "windows-targets 0.52.4", +] + +[[package]] +name = "windows-core" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" +dependencies = [ + "windows-result", + "windows-targets 0.52.4", ] [[package]] name = "windows-implement" -version = "0.44.0" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce87ca8e3417b02dc2a8a22769306658670ec92d78f1bd420d6310a67c245c6" +checksum = "942ac266be9249c84ca862f0a164a39533dc2f6f33dc98ec89c8da99b82ea0bd" dependencies = [ "proc-macro2", "quote", @@ -385,77 +380,153 @@ dependencies = [ [[package]] name = "windows-interface" -version = "0.44.0" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "853f69a591ecd4f810d29f17e902d40e349fb05b0b11fff63b08b826bfe39c7f" +checksum = "da33557140a288fae4e1d5f8873aaf9eb6613a9cf82c3e070223ff177f598b60" dependencies = [ "proc-macro2", "quote", "syn", ] +[[package]] +name = "windows-result" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd19df78e5168dfb0aedc343d1d1b8d422ab2db6756d2dc3fef75035402a3f64" +dependencies = [ + "windows-targets 0.52.4", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" [[package]] name = "winreg" -version = "0.10.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" dependencies = [ - "winapi", + "cfg-if", + "windows-sys", ] diff --git a/Cargo.toml b/Cargo.toml index 431b207..f35575b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,12 +11,12 @@ crate-type = ["rlib", "cdylib"] [dependencies] simple-logging = "2.0.2" -log = "0.4.17" -winreg = "0.10.1" -jxl-oxide = "0.5.1" +log = "0.4.21" +winreg = "0.52.0" +jxl-oxide = "0.7.1" [dependencies.windows] -version = "0.44.0" +version = "0.54.0" features = [ "implement", "Win32_Graphics_Imaging", diff --git a/README.md b/README.md index 94a837d..4585b66 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,11 @@ A JPEG XL (*.jxl) WIC decoder to render thumbnails on Windows File Explorer or v 1. Move to your download directory 1. `regsvr32 jxl_winthumb.dll`, or to uninstall, `regsvr32 /u jxl_winthumb.dll`. +You might need to restart `explorer.exe` or any programs that use the dll before updating it. Get the list of such programs using `tasklist /m jxl_winthumb.dll` and kill them e.g. with `taskkill /f /im explorer.exe && start explorer.exe`. + ## Build environment -Use the stable Rust toolchain. Current toolchain as of 23th July 2023 is 1.71.0. +Use the stable Rust toolchain. Current toolchain as of 26th February 2024 is 1.75.0. ## Helpful resources diff --git a/src/dll.rs b/src/dll.rs index 445c9d3..f8b072c 100644 --- a/src/dll.rs +++ b/src/dll.rs @@ -26,7 +26,7 @@ struct ClassFactory {} impl IClassFactory_Impl for ClassFactory { fn CreateInstance( &self, - outer: &Option, + outer: Option<&windows::core::IUnknown>, iid: *const GUID, object: *mut *mut core::ffi::c_void, ) -> windows::core::Result<()> { @@ -37,11 +37,11 @@ impl IClassFactory_Impl for ClassFactory { match *iid { windows::Win32::Graphics::Imaging::IWICBitmapDecoder::IID => { let unknown: IUnknown = JXLWICBitmapDecoder::default().into(); - unknown.query(&*iid, object as _).ok() + unknown.query(iid, object).ok() } windows::Win32::UI::Shell::PropertiesSystem::IPropertyStore::IID => { let unknown: IUnknown = JXLPropertyStore::default().into(); - unknown.query(&*iid, object as _).ok() + unknown.query(iid, object).ok() } _ => { log::trace!("Unknown IID: {:?}", *iid); @@ -113,7 +113,7 @@ pub extern "stdcall" fn DllMain( pub unsafe extern "system" fn DllGetClassObject( rclsid: *const GUID, riid: *const GUID, - pout: *mut *const core::ffi::c_void, + pout: *mut *mut core::ffi::c_void, ) -> HRESULT { // Sets up logging to the Cargo.toml directory for debug purposes. #[cfg(debug_assertions)] @@ -134,7 +134,7 @@ pub unsafe extern "system" fn DllGetClassObject( let unknown: IUnknown = factory.into(); match *rclsid { - JXLWICBitmapDecoder::CLSID | JXLPropertyStore::CLSID => unknown.query(&*riid, pout), + JXLWICBitmapDecoder::CLSID | JXLPropertyStore::CLSID => unknown.query(riid, pout), _ => CLASS_E_CLASSNOTAVAILABLE, } } diff --git a/src/lib.rs b/src/lib.rs index a79c359..dc88fc0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,7 +46,7 @@ impl JXLWICBitmapDecoder { } impl IWICBitmapDecoder_Impl for JXLWICBitmapDecoder { - fn QueryCapability(&self, _pistream: &Option) -> windows::core::Result { + fn QueryCapability(&self, _pistream: Option<&IStream>) -> windows::core::Result { log::trace!("QueryCapability"); Ok((WICBitmapDecoderCapabilityCanDecodeSomeImages.0 | WICBitmapDecoderCapabilityCanDecodeAllImages.0) as u32) @@ -54,16 +54,16 @@ impl IWICBitmapDecoder_Impl for JXLWICBitmapDecoder { fn Initialize( &self, - pistream: &Option, + pistream: Option<&IStream>, _cacheoptions: WICDecodeOptions, ) -> windows::core::Result<()> { log::trace!("JXLWICBitmapDecoder::Initialize"); - let stream = WinStream::from(pistream.to_owned().unwrap()); + let stream = WinStream::from(pistream.unwrap()); let reader = BufReader::new(stream); - let image = JxlImage::from_reader(reader).map_err(|err| { - windows::core::Error::new(WINCODEC_ERR_BADIMAGE, format!("{:?}", err).as_str().into()) + let image = JxlImage::builder().read(reader).map_err(|err| { + windows::core::Error::new(WINCODEC_ERR_BADIMAGE, format!("{:?}", err)) })?; let (width, height, _left, _top) = image.image_header().metadata.apply_orientation( @@ -102,7 +102,7 @@ impl IWICBitmapDecoder_Impl for JXLWICBitmapDecoder { } } - fn CopyPalette(&self, _pipalette: &Option) -> windows::core::Result<()> { + fn CopyPalette(&self, _pipalette: Option<&IWICPalette>) -> windows::core::Result<()> { log::trace!("JXLWICBitmapDecoder::CopyPalette"); // TODO WINCODEC_ERR_PALETTEUNAVAILABLE.ok() @@ -183,10 +183,7 @@ impl IWICBitmapDecoder_Impl for JXLWICBitmapDecoder { } let render = decoded.image.render_frame(index as usize).map_err(|err| { - windows::core::Error::new( - WINCODEC_ERR_FRAMEMISSING, - format!("{:?}", err).as_str().into(), - ) + windows::core::Error::new(WINCODEC_ERR_FRAMEMISSING, format!("{:?}", err)) })?; let frame_decode = JXLWICBitmapFrameDecode::new( @@ -250,16 +247,13 @@ impl IWICBitmapSource_Impl for JXLWICBitmapFrameDecode { PixelFormat::Gray => Ok(GUID_WICPixelFormat32bppGrayFloat), PixelFormat::Graya => Err(windows::core::Error::new( WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT, - "Gray alpha image is currently not supported".into(), + "Gray alpha image is currently not supported", )), PixelFormat::Rgb => Ok(GUID_WICPixelFormat96bppRGBFloat), PixelFormat::Rgba => Ok(GUID_WICPixelFormat128bppRGBAFloat), - jxl_oxide::PixelFormat::Cmyk | jxl_oxide::PixelFormat::Cmyka => { - Err(windows::core::Error::new( - WINCODEC_ERR_BADIMAGE, - "Cmyk is currently not supported".into(), - )) - } + jxl_oxide::PixelFormat::Cmyk | jxl_oxide::PixelFormat::Cmyka => Err( + windows::core::Error::new(WINCODEC_ERR_BADIMAGE, "Cmyk is currently not supported"), + ), } } @@ -273,7 +267,7 @@ impl IWICBitmapSource_Impl for JXLWICBitmapFrameDecode { Ok(()) } - fn CopyPalette(&self, _pipalette: &Option) -> windows::core::Result<()> { + fn CopyPalette(&self, _pipalette: Option<&IWICPalette>) -> windows::core::Result<()> { log::trace!("JXLWICBitmapFrameDecode::CopyPalette"); WINCODEC_ERR_PALETTEUNAVAILABLE.ok() } diff --git a/src/properties.rs b/src/properties.rs index e6623f4..d98f4c7 100644 --- a/src/properties.rs +++ b/src/properties.rs @@ -1,15 +1,16 @@ use std::io::BufReader; use windows as Windows; -use windows::core::{implement, Interface, GUID, HSTRING, PCWSTR}; +use windows::core::{implement, Interface, GUID, HSTRING, PCWSTR, PROPVARIANT}; use windows::Win32::{ Foundation::*, - System::Com::IStream, - System::Com::StructuredStorage::PROPVARIANT, + System::Com::{ + IStream, + StructuredStorage::{InitPropVariantFromStringVector, InitPropVariantFromUInt32Vector}, + }, UI::Shell::PropertiesSystem::{ IInitializeWithStream_Impl, IPropertyStoreCache, IPropertyStoreCapabilities_Impl, - IPropertyStore_Impl, InitPropVariantFromStringVector, InitPropVariantFromUInt32Vector, - PSCreateMemoryPropertyStore, PROPERTYKEY, PSC_READONLY, + IPropertyStore_Impl, PSCreateMemoryPropertyStore, PROPERTYKEY, PSC_READONLY, }, }; @@ -33,7 +34,7 @@ impl JXLPropertyStore { if self.props.is_none() { return Err(windows::core::Error::new( WINCODEC_ERR_NOTINITIALIZED, - "Property store not initialized".into(), + "Property store not initialized", )); } @@ -42,12 +43,12 @@ impl JXLPropertyStore { } impl IInitializeWithStream_Impl for JXLPropertyStore { - fn Initialize(&self, pstream: &Option, _grfmode: u32) -> windows::core::Result<()> { - let stream = WinStream::from(pstream.to_owned().unwrap()); + fn Initialize(&self, pstream: Option<&IStream>, _grfmode: u32) -> windows::core::Result<()> { + let stream = WinStream::from(pstream.unwrap()); let reader = BufReader::new(stream); - let image = JxlImage::from_reader(reader).map_err(|err| { - windows::core::Error::new(WINCODEC_ERR_BADIMAGE, format!("{:?}", err).as_str().into()) + let image = JxlImage::builder().read(reader).map_err(|err| { + windows::core::Error::new(WINCODEC_ERR_BADIMAGE, format!("{:?}", err)) })?; let (width, height, _left, _top) = image.image_header().metadata.apply_orientation( @@ -125,14 +126,14 @@ impl IPropertyStore_Impl for JXLPropertyStore { ) -> windows::core::Result<()> { Err(windows::core::Error::new( WINCODEC_ERR_UNSUPPORTEDOPERATION, - "Setter not supported".into(), + "Setter not supported", )) } fn Commit(&self) -> windows::core::Result<()> { Err(windows::core::Error::new( WINCODEC_ERR_UNSUPPORTEDOPERATION, - "Setter not supported".into(), + "Setter not supported", )) } } @@ -141,7 +142,7 @@ impl IPropertyStoreCapabilities_Impl for JXLPropertyStore { fn IsPropertyWritable(&self, _key: *const PROPERTYKEY) -> windows::core::Result<()> { Err(windows::core::Error::new( WINCODEC_ERR_UNSUPPORTEDOPERATION, - "Setter not supported".into(), + "Setter not supported", )) } } diff --git a/src/winstream.rs b/src/winstream.rs index 5373171..fe6f84a 100644 --- a/src/winstream.rs +++ b/src/winstream.rs @@ -2,17 +2,17 @@ use std::io::{ErrorKind, Read}; use windows::Win32::System::Com::IStream; -pub struct WinStream { - stream: IStream, +pub struct WinStream<'a> { + stream: &'a IStream, } -impl From for WinStream { - fn from(stream: IStream) -> Self { +impl<'a> From<&'a IStream> for WinStream<'a> { + fn from(stream: &'a IStream) -> Self { Self { stream } } } -impl Read for WinStream { +impl<'a> Read for WinStream<'a> { fn read(&mut self, buf: &mut [u8]) -> Result { let mut bytes_read = 0u32; unsafe { diff --git a/tests/wic.rs b/tests/wic.rs index 7c5f61b..78707e6 100644 --- a/tests/wic.rs +++ b/tests/wic.rs @@ -5,7 +5,7 @@ use windows::Win32::UI::Shell::SHCreateMemStream; #[test] fn basic() { - unsafe { CoInitialize(None) }.expect("CoInitialize"); + unsafe { CoInitialize(None) }.ok().expect("CoInitialize"); let mem = std::fs::read("tests/alien.jxl").expect("Read the test file"); let stream = unsafe { SHCreateMemStream(Some(&mem[..])) }.expect("Create an IStream");