diff --git a/app/src/components/SceneCanvas.tsx b/app/src/components/SceneCanvas.tsx index b554703..fca7dc9 100644 --- a/app/src/components/SceneCanvas.tsx +++ b/app/src/components/SceneCanvas.tsx @@ -41,6 +41,7 @@ function CanvasInner({ fallback: _, shadows, ...canvasProps }: SceneCanvasProps) return ( { diff --git a/app/src/lib/canvas-capture.ts b/app/src/lib/canvas-capture.ts index 5a20676..ce1f952 100644 --- a/app/src/lib/canvas-capture.ts +++ b/app/src/lib/canvas-capture.ts @@ -73,9 +73,8 @@ export async function captureCanvasImage( outW = Math.round((outH / srcH) * srcW); } - if (outW === srcW && outH === srcH) { - return canvasToDataURL(canvas, format, quality); - } + // Removido o short-circuit (outW === srcW) para forçar a passagem pelo canvas 2D + // e garantir que o fundo transparente seja preenchido de branco. const off = document.createElement('canvas'); off.width = outW; @@ -85,6 +84,11 @@ export async function captureCanvasImage( ctx.imageSmoothingEnabled = true; ctx.imageSmoothingQuality = 'high'; + + // Preencher fundo com branco para evitar preto em áreas transparentes (especialmente em JPEGs ou PDFs) + ctx.fillStyle = '#ffffff'; + ctx.fillRect(0, 0, outW, outH); + ctx.drawImage(canvas, 0, 0, outW, outH); return off.toDataURL(`image/${format}`, quality);