@@ -75,8 +75,13 @@ export class ElectronPngWriterService implements IPngCreatorService {
7575 const totalWidth = Math . ceil ( maxX - minX ) ;
7676 const totalHeight = Math . ceil ( maxY - minY ) ;
7777
78- const viewportW = designerCanvas . canvas . offsetWidth ;
79- const viewportH = designerCanvas . canvas . offsetHeight ;
78+ // Use the outer viewport element to determine the capture rectangle
79+ // so that coordinates are not affected by the canvasOffset CSS transform.
80+ // Its dimensions reflect the actual visible capture area, which may
81+ // differ from canvas.offsetWidth when designerWidth/Height != 100%.
82+ const viewportElement = ( < DesignerCanvas > designerCanvas ) . outercanvas2 ;
83+ const viewportW = viewportElement . offsetWidth ;
84+ const viewportH = viewportElement . offsetHeight ;
8085
8186 // Inset by 1 CSS pixel on each edge to avoid border artifacts when stitching tiles
8287 const borderInset = 1 ;
@@ -98,10 +103,6 @@ export class ElectronPngWriterService implements IPngCreatorService {
98103 finalCanvas . height = Math . ceil ( totalHeight * dpr ) ;
99104 const finalCtx = finalCanvas . getContext ( '2d' ) ;
100105
101- // Use the outer viewport element to determine the capture rectangle
102- // so that coordinates are not affected by the canvasOffset CSS transform
103- const viewportElement = ( < DesignerCanvas > designerCanvas ) . outercanvas2 ;
104-
105106 for ( let iy = 0 ; iy < numTilesY ; iy ++ ) {
106107 for ( let ix = 0 ; ix < numTilesX ; ix ++ ) {
107108 const tileX = minX + ix * effectiveW ;
0 commit comments