* Show image in canvas. * * @param dataRGBA Image array in height x width uint32 Tensor RGBA format on GPU.
(dataRGBA: Tensor)
| 1619 | * @param dataRGBA Image array in height x width uint32 Tensor RGBA format on GPU. |
| 1620 | */ |
| 1621 | showImage(dataRGBA: Tensor) { |
| 1622 | if (dataRGBA.shape.length != 2) { |
| 1623 | throw Error("Require a height x width uint32 Tensor in RGBA" + |
| 1624 | "get shape=" + dataRGBA.shape.toString() + " instead." |
| 1625 | ); |
| 1626 | } |
| 1627 | if (dataRGBA.device.deviceType != DeviceStrToEnum.webgpu) { |
| 1628 | throw new Error("Can only run showImage on WebGPU array, " + |
| 1629 | "get " + DeviceEnumToStr[dataRGBA.device.deviceType] + " instead."); |
| 1630 | } |
| 1631 | if (dataRGBA.dtype != "uint32") { |
| 1632 | throw Error("Require a height x width uint32 Tensor in RGBA, " + |
| 1633 | "get " + dataRGBA.dtype + " instead."); |
| 1634 | } |
| 1635 | this.lib.webGPUContext?.drawImageFromBuffer( |
| 1636 | dataRGBA.getDataPtr(), dataRGBA.shape[0], dataRGBA.shape[1] |
| 1637 | ); |
| 1638 | } |
| 1639 | |
| 1640 | /** |
| 1641 | * Clear canvas |
nothing calls this directly
no test coverage detected