mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-28 22:30:47 -08: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.