mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-29 09:46:19 +01:00
The new apps/vectorcraft-thumbnail-handler crate builds vectorcraft_thumbnail_handler.dll, a thumbnail handler (IThumbnailProvider with IInitializeWithStream) for .vectorcraft, .drawcraft and .vctemplate files. Explorer passes it the file's bytes. It writes them to a file in %USERPROFILE%\AppData\LocalLow\VectorCraft\Thumbnails (the temp folder when that can't be made), runs `vectorcraft-cli thumbnail --size N` from the DLL's folder on that file, and returns the PNG as a top-down 32-bit bitmap with premultiplied alpha, at most 1024 pixels on its longer side. A file larger than 256 MiB, a failed run, or a run longer than 25 seconds returns an error, and Explorer shows the file's icon. Explorer gives the handler the file's bytes and not its path, so a linked image found only relative to the document's folder shows the preview saved with it. `regsvr32 vectorcraft_thumbnail_handler.dll` registers the handler for the current user under HKCU\Software\Classes, and `regsvr32 /u` removes the class key and each extension's ShellEx key that names it. The Windows packages do not build, ship or register the DLL yet. The COM code is Windows-only and has a module-scoped unsafe_code allowance. The registry values, the stream limit, the PNG conversion and the vectorcraft-cli run build on every system, and their tests run in CI.
34 lines
952 B
TOML
34 lines
952 B
TOML
[package]
|
|
name = "vectorcraft-thumbnail-handler"
|
|
description = "Windows Explorer thumbnail handler for VectorCraft documents and templates"
|
|
version.workspace = true
|
|
edition.workspace = true
|
|
license.workspace = true
|
|
publish = false
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
# A COM server DLL that Explorer loads; on other systems it builds the parts the tests check.
|
|
[lib]
|
|
crate-type = ["cdylib"]
|
|
|
|
# PNG decoding of the picture `vectorcraft-cli thumbnail` writes. MIT OR Apache-2.0.
|
|
[dependencies]
|
|
png = "0.18"
|
|
|
|
# IThumbnailProvider, IInitializeWithStream, the class factory, DIB sections and the registry.
|
|
# MIT OR Apache-2.0.
|
|
[target.'cfg(windows)'.dependencies]
|
|
windows = { version = "0.62", features = [
|
|
"Win32_Foundation",
|
|
"Win32_Graphics_Gdi",
|
|
"Win32_System_Com",
|
|
"Win32_System_LibraryLoader",
|
|
"Win32_System_Registry",
|
|
"Win32_System_SystemServices",
|
|
"Win32_UI_Shell",
|
|
"Win32_UI_Shell_PropertiesSystem",
|
|
] }
|
|
windows-core = "0.62"
|