Bildressource in imageDataFromFile mit try/finally freigeben
Stelle sicher, dass bitmap.close() auch bei Fehler aufgerufen wird. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+7
-4
@@ -67,8 +67,11 @@ export function grabFrame(videoElement, maxEdge = 1280) {
|
|||||||
/** Ersatzweg ohne Kamera: Bilddatei auswaehlen (z. B. am Rechner). */
|
/** Ersatzweg ohne Kamera: Bilddatei auswaehlen (z. B. am Rechner). */
|
||||||
export async function imageDataFromFile(file, maxEdge = 1280) {
|
export async function imageDataFromFile(file, maxEdge = 1280) {
|
||||||
const bitmap = await createImageBitmap(file);
|
const bitmap = await createImageBitmap(file);
|
||||||
assertHasSize(bitmap.width, bitmap.height);
|
try {
|
||||||
const data = drawScaled(bitmap, bitmap.width, bitmap.height, maxEdge);
|
assertHasSize(bitmap.width, bitmap.height);
|
||||||
bitmap.close();
|
const data = drawScaled(bitmap, bitmap.width, bitmap.height, maxEdge);
|
||||||
return data;
|
return data;
|
||||||
|
} finally {
|
||||||
|
bitmap.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user