From 83614da9090bfd0a59d0fffeaca94a1a5a674f2e Mon Sep 17 00:00:00 2001 From: Christian Mahnke Date: Tue, 9 Jul 2024 15:39:15 +0200 Subject: [PATCH] Added clone --- package.json | 2 +- src/Uint16Image.ts | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 04d7b1a..8bd14ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hdr-canvas", - "version": "0.0.3", + "version": "0.0.4", "description": "HDR capable HTML canvas", "main": "dist/hdr-canvas.js", "files": [ diff --git a/src/Uint16Image.ts b/src/Uint16Image.ts index b0e5f12..d794cb5 100644 --- a/src/Uint16Image.ts +++ b/src/Uint16Image.ts @@ -67,7 +67,7 @@ export class Uint16Image { this.data[pos + 3] = px[3]; } - // Only use this for aplha, since it doesn't to color space conversions + // Only use this for alpha, since it doesn't to color space conversions static scaleUint8ToUint16(val: number): number { return (val << 8) | val; } @@ -181,4 +181,10 @@ export class Uint16Image { } this.colorSpace = Uint16Image.DEFAULT_COLORSPACE; } + + clone(): Uint16Image { + const i = new Uint16Image(this.width, this.height, this.colorSpace); + i.data = this.data.slice(); + return i; + } }