resliceBufferWithPadding
import { resliceBufferWithPadding } from "jsr:@ende/webgpu";function
function resliceBufferWithPadding(buffer: Uint8Array, width: number, height: number): Uint8ArrayCreates a new buffer while removing any unnecessary empty bytes. Useful for when wanting to save an image as a specific format.
buffer: Uint8ArrayThe buffer to reslice.
width: numberThe width of the output buffer.
height: numberThe height of the output buffer.
Returns
The resliced buffer.
Example: Usage
import { resliceBufferWithPadding } from "@ende/webgpu/row-padding";
import { assertEquals } from "@ende/assert";
const input = new Uint8Array([0, 255, 0, 255, 120, 120, 120]);
const result = resliceBufferWithPadding(input, 1, 1);
assertEquals(result, new Uint8Array([0, 255, 0, 255]));