Add an SVG export option to store pictures smaller

An SVG keeps every picture at full resolution, whatever size it is
drawn at: a folio with 22 phone photos shown at a tenth of their size
gave a 270 MB SVG and took 65 s to write, most of it compressing the
photos again.

The export dialog gets "SVG: smaller pictures" (off by default, kept
with the other export settings), and --export-svg gets
--svg-small-pictures. With it, a picture is stored at four times the
size it is drawn at when that is smaller than the picture; smaller
pictures stay whole. Four times is about 375 dpi on a printed folio.

The exporter sets Diagram::smallPictures() for its own drawing only,
so screen, print, PDF and PNG are unchanged. It is not part of
applyProperties(), which every format uses.

On that project: --export-svg 84.9 s -> 34.5 s (opening is 20 s of
both), 270 MB -> 57 MB, peak memory 2.45 -> 1.86 GB. Rendered at twice
the folio size, the two SVGs differ by more than 32/255 on 0.23 % of
pixels, along photo detail.

tst_svgsmallpictures: an 800x600 picture drawn at 0.1 is stored at
320x240 with the option, through --export-svg and through the
dialog's QPicture route, and at 800x600 without it; a 40x30 picture
stays whole. It fails when the factor is changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-10-14 13:12:38 +13:00
parent 8b680af938
commit da6eb83035
12 changed files with 252 additions and 4 deletions
+2
View File
@@ -417,12 +417,14 @@ void ExportDialog::generateSvg(
// genere une QPicture a partir du schema
QPicture picture;
diagram -> setSmallPictures(epw -> exportProperties().svg_small_pictures);
diagram -> toPaintDevice(
picture,
width,
height,
keep_aspect_ratio ? Qt::KeepAspectRatio : Qt::IgnoreAspectRatio
);
diagram -> setSmallPictures(false);
// "joue" la QPicture sur un QSvgGenerator
QSvgGenerator svg_engine;