Function · Desktop Services
renderDrawingToPng
Renders a validated drawing document to a transparency-preserving PNG file.
@sharpts/gui · SharpTS 572a2e31be0eSignature
TypeScript
renderDrawingToPng(document: DrawingDocument, path: string): Promise<void>Parameters
| Name | Type | Description |
|---|---|---|
document | DrawingDocument | Bounded drawing document to composite and encode. |
path | string | Local destination path for the PNG file. |
Returns
Promise<void> — A promise completed after the PNG file is written.
Remarks
Rendering occurs off the UI thread. The destination is replaced atomically after the PNG has been encoded successfully.
Throws
- When the document is invalid or exceeds 8,192 pixels per dimension, an image source is invalid, or the destination cannot be written.
Examples
TypeScript
import { renderDrawingToPng } from "@sharpts/gui";
await renderDrawingToPng({
width: 320,
height: 180,
background: "#ffffff",
layers: []
}, "output/preview.png");Related symbols
Source
src/SharpTS.Gui.Sdk/GuiPackage/runtime.ts:1534 at SharpTS revision 572a2e31be0e2a09be0138bc44501b34d6245b51.