Conversation
ResizeForPreview 在最长边 > 2048px 时下采样预览图,使其小于 summary 坐标系;object-fit: none 按图片自身尺寸绘制导致点击选区错位。改为 fill 铺满坐标盒子。补充 Neroued#83(仅修上采样方向)未覆盖的下采样场景。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更类型
变更说明
问题背景
ResizeForPreview在光栅 recipe map 最长边超过kPreviewMaxDim (2048)时会下采样预览 PNG,使其分辨率小于summary.width/height。而ZoomableImageViewport的<img>盒子按contentWidth/contentHeight(= summary 全分辨率)设置,却使用object-fit: none,导致预览图按自身较小尺寸居中绘制,与叠加层 canvas、点击坐标映射(都基于 summary 全分辨率坐标系)错位。表现:当输出像素长边超过 2048 时,在配方编辑器点击色块,高亮选区与实际位置偏移。
复现:
p0.png(804×1200),目标高度设为 240mm(参数面板提示“输出约 1608×2400 像素”),长边 2400 > 2048,进入配方编辑器点击色块即偏移;目标高度 ≤ ~205mm(输出 ≤ 2048px)时预览图不被下采样,不触发。解决方案
将
imgStyle中的object-fit: none改为fill,让预览图铺满 summary 坐标盒子,从而与叠加层和点击映射对齐。与 #83 的关系:
object-fit: none按图片自身尺寸绘制)。min_dim默认 512 造成放大的回归)。ResizeForPreview为等比缩放,盒子长宽比与预览图一致,fill不产生可见变形;未触发 resize 时none/fill效果相同,无回归。两个 resize 方向(含 fix: 禁用光栅预览默认上采样,避免坐标映射偏移 #83 的上采样场景)一并覆盖。影响范围
core/— C++ 核心算法(图像处理、配方匹配、体素/网格、3MF)apps/— CLI 工具web/backend/— Drogon HTTP APIweb/frontend/— Vue3 前端modeling/— Python 建模与拟合流水线docs/— 文档验证记录
npm run build:typecheck + vite build 通过)验证详情(可选,展开填写)
前端构建(electron 目标)通过:
手动复现与验证:
p0.png804×1200,目标高度 240mm(输出约 1608×2400 像素)。修复前点击色块选区偏移,修复后选区与点击位置一致。代码质量检查
clang-format -i <modified-files>(本次无 C++ 改动,N/A).cpp文件结构清晰(本次无.cpp改动,N/A)文档与协作同步
README.md、docs/development.md、docs/agents/web/backend/README.md、docs/development.md、docs/agents/apps/README.md、docs/deployment.mdREADME.md、docs/agents/web/frontend/data/preset_bases/变化 → 已同步docs/agents/tasks/extend_machine_support.md、docs/development.mdAGENTS.md与对应模块索引docs/agents/tasks/端到端联动检查
联动检查(如不涉及可跳过,展开填写)
本次为纯前端渲染样式修复,不涉及 API / runtime / cache / 下载链路 / 文件落盘,故不适用。
风险与回滚
风险点: 低。改动仅影响配方编辑器预览图的 CSS
object-fit。预览图未触发 resize 时fill与none效果一致;触发时因等比缩放,fill仅将预览图拉伸铺满原本就等比的盒子,无可见变形,且与坐标系对齐。回滚方案: 回退本次提交即可(单文件一行改动)。
截图 / 演示
修复前:


修复后: