mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-14 21:44:57 +00:00
The image crate's filtered resize filters each channel on its own, which is correct only for premultiplied pixels, and its thumbnail averages each channel on its own too. Placed images, linked-image previews, MCP captures and previews, metafile bitmaps, PDF downsampling and library thumbnails passed straight RGBA to them, so the color under clear pixels (usually black) bled into the opaque pixels beside them and darkened cut-out edges. vectorcraft_doc::resample scales such images with each pixel's color weighted by its alpha: filtered resampling premultiplies the pixels in place and divides them back after, and averaging takes the area-weighted mean of the pixels each new one covers. Opaque and alpha-free images are scaled as before. PDF export also multiplies the inks of a CMYK image with alpha by that alpha before resampling them, and divides them by the resampled alpha after.