Conversation
This branch has not been deployed
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.
任务简述
修复 “将所选区域导出为图片” 功能及相关格式支持(详见 dev-agent-6103 任务文档
devel/6103.stem)。问题原因
make_raster_image中,save_picture (name, pic)位于tm_delete (ren)之前被调用。MuPDF 的run_processor与draw_device针对当前文本块的操作在end_text/end()调用前处于缓冲状态,尚未刷新提交到 pixmap。因此最后一行文本未能绘制进 pixmap 就已保存到磁盘。src/Plugins/MuPDF/mupdf_picture.cpp的save_picture函数硬编码了if (suffix (dest) != "png") return;,对除 PNG 外的格式直接告警并不予保存;tmimage.scm与file-menu.scm错误地对原生支持的位图导出格式(png、jpeg、tif)检查外部 PDF 格式转换器file-converter-exists? "x.pdf" ...,在缺少 ImageMagick/pdftocairo 等外部工具的环境下抛弃或破坏导出路径(如拼接为pngpdf)。解决方案
make_raster_image中先执行tm_delete (ren)析构渲染器,确保end_text和设备关闭操作将所有绘图命令完整刷新至 pixmap,再调用save_picture (name, pic)保存图片。mupdf_picture.cpp的save_picture中,借助 Qt (QImage::save) 支持导出 PNG、JPEG、TIFF 等丰富格式,并提供 MuPDF 原生fz_write_pixmap_as_png和fz_write_pixmap_as_jpeg回退;tmimage.scm与file-menu.scm中,原生导出的图片格式(png, jpeg, tif)不再受制于外部 PDF 转换器是否存在;tmimage.scm中降级到 PDF 时的文件名子串截取偏移 bug。TeXmacs/tests/6103.scm,覆盖 png、jpeg、tif 格式多行及单行导出验证。