mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 08:46:55 +08:00
feat(编辑渲染): 完善三维转换,优化编辑渲染压缩
This commit is contained in:
1 parent
e8344e6387
commit
839f65e3d7
47 files changed
+4887
-112
No files matched your search
@@ -435,6 +435,13 @@ func (p *pdfImporter) groupSceneBounds(scene *RasterPage) (*RasterPage, Box, err
|
||||
// 入参: source 原始场景, box 页面裁取区域
|
||||
// 返回: image.Image 透明图像, error 后端渲染错误
|
||||
func (p *pdfImporter) renderGroupScene(source *RasterPage, box Box) (image.Image, error) {
|
||||
return p.renderGroupSceneInto(source, box, nil)
|
||||
}
|
||||
|
||||
// renderGroupSceneInto 在指定区域绘制场景,按所选后端能力复用独占目标
|
||||
// 入参: source 原始场景, box 页面裁取区域, target 可选目标缓冲
|
||||
// 返回: image.Image 透明图像, error 后端渲染错误
|
||||
func (p *pdfImporter) renderGroupSceneInto(source *RasterPage, box Box, target *image.RGBA) (image.Image, error) {
|
||||
scene := *source
|
||||
scene.DPI = p.rasterDPI
|
||||
scene.Commands = append([]RasterCommand(nil), source.Commands...)
|
||||
@@ -457,6 +464,14 @@ func (p *pdfImporter) renderGroupScene(source *RasterPage, box Box) (image.Image
|
||||
if backend == nil {
|
||||
return nil, fmt.Errorf("PDF local compositing: %w", ErrBackendUnavailable)
|
||||
}
|
||||
if target != nil {
|
||||
if buffered, ok := backend.(RasterBufferBackend); ok {
|
||||
if err := buffered.RenderInto(&scene, target); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
}
|
||||
return backend.Render(&scene)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user