Skip to content
Snippets Groups Projects
Verified Commit f634cd15 authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

chore: small util improvement

parent 8e1d045c
No related branches found
No related tags found
1 merge request!32Support for BOS format structure
Pipeline #3324 passed
......@@ -28,9 +28,14 @@ export const bufferToImageData = (
*
* @param buffer The array of bytes containing the image data.
* @param width The width of the image in the buffer.
* @param format The format of the image as a MIME string.
* @returns The resulting data URL.
*/
export const bufferToDataUrl = (buffer: Uint8Array, width: number): string => {
export const bufferToDataUrl = (
buffer: Uint8Array,
width: number,
format = "image/png"
): string => {
const imageData = bufferToImageData(buffer, width);
const canvas = document.createElement("canvas");
......@@ -40,6 +45,6 @@ export const bufferToDataUrl = (buffer: Uint8Array, width: number): string => {
const context = canvas.getContext("2d");
context?.putImageData(imageData, 0, 0);
const dataUrl = canvas.toDataURL();
const dataUrl = canvas.toDataURL(format);
return dataUrl;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment