MCPcopy Create free account
hub / github.com/melonjs/melonJS / decodeBase64Image

Function decodeBase64Image

packages/melonjs/src/utils/decode.ts:123–139  ·  view source on GitHub ↗
(
	base64: string,
	format: string = "png",
	width?: number,
	height?: number,
)

Source from the content-addressed store, hash-verified

121};
122
123export function decodeBase64Image(
124 base64: string,
125 format: string = "png",
126 width?: number,
127 height?: number,
128): HTMLImageElement {
129 const img = new Image();
130 if (width != null) {
131 img.width = width;
132 }
133 if (height != null) {
134 img.height = height;
135 }
136 const mime = mimeTypes[format] || `image/${format}`;
137 img.src = `data:${mime};base64,${base64}`;
138 return img;
139}
140
141/**
142 * Decode an encoded array into a binary array

Callers 2

cacheEmbeddedImageFunction · 0.90
tmxutils.spec.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected