Skip to content

Commit

Permalink
Merge branch 'main' into _private
Browse files Browse the repository at this point in the history
  • Loading branch information
rwv committed Nov 18, 2023
2 parents cbfd6be + 8ca026b commit 4110e20
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utils/scan-renderer/canvas-scan/scan-canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export async function scanCanvas(
throw new Error('Aborted')
}

const imgPromise = createImageBitmap(page)
const noiseImagePromise = createImageBitmap(noise)

// Note: Hack to get around TS error
const ctx = canvas.getContext('2d') as
| CanvasRenderingContext2D
Expand All @@ -20,7 +23,7 @@ export async function scanCanvas(
}

// load blob into image
const img = await createImageBitmap(page)
const img = await imgPromise
if (signal?.aborted) {
throw new Error('Aborted')
}
Expand Down Expand Up @@ -54,7 +57,7 @@ export async function scanCanvas(

ctx.drawImage(img, 0, 0)

const noiseImage = await createImageBitmap(noise)
const noiseImage = await noiseImagePromise
ctx.drawImage(noiseImage, 0, 0, width, height)

if (config.border) {
Expand Down

0 comments on commit 4110e20

Please sign in to comment.