itwinjs-core icon indicating copy to clipboard operation
itwinjs-core copied to clipboard

Add a size prop to Viewport.readImageToCanvas.

Open jzbuchalski opened this issue 4 months ago • 1 comments

The viewport image can be captured through Viewport.readImageBuffer. This routine provides a size prop, scaling the target image accordingly based on the aspect ratio. This function does not include an option to contain/omit canvas decorations.

The viewport and canvas decorations can be captured through Viewport.readImageToCanvas. This function does contain a prop to include/omit decorations, but not a size prop.

Can a size prop be added to Viewport.readImageToCanvas (and honor the aspect ratio as in readImageBuffer)?

Use case: We create thumbnails of the viewport and store the resulting images (.png) in the cloud. We try to keep the file size (thumbnail) reasonable.

@markschlosseratbentley

jzbuchalski avatar Oct 20 '25 20:10 jzbuchalski

Any reason you can't just resize the resultant image yourself? We'd have to do the same thing for you. I think it makes more sense for the viewport to handle reading the image off the GPU and let callers apply whatever post-processing they want.

pmconne avatar Oct 20 '25 20:10 pmconne