fix: initialize DICOM decoder modules in browser workers
This commit is contained in:
1 parent
dd29258828
commit
7a1d18dfc6
8 files changed
+105
-41
No files matched your search
@@ -1,44 +1,7 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { storedValue, windowPixel } from "../dicom-pixels";
|
||||
|
||||
function fixture() {
|
||||
const data: number[] = [...new Uint8Array(128), 68, 73, 67, 77];
|
||||
const add = (group: number, element: number, vr: string, bytes: number[]) => {
|
||||
if (bytes.length % 2) bytes.push(vr === "UI" ? 0 : 32);
|
||||
data.push(
|
||||
group & 255,
|
||||
group >> 8,
|
||||
element & 255,
|
||||
element >> 8,
|
||||
vr.charCodeAt(0),
|
||||
vr.charCodeAt(1)
|
||||
);
|
||||
if (["OB", "OW"].includes(vr))
|
||||
data.push(0, 0, bytes.length & 255, bytes.length >> 8, 0, 0);
|
||||
else data.push(bytes.length & 255, bytes.length >> 8);
|
||||
data.push(...bytes);
|
||||
};
|
||||
const text = (s: string) => Array.from(new TextEncoder().encode(s));
|
||||
add(2, 0x10, "UI", text("1.2.840.10008.1.2.1"));
|
||||
add(0x28, 2, "US", [1, 0]);
|
||||
add(0x28, 4, "CS", text("MONOCHROME2"));
|
||||
add(0x28, 8, "IS", text("2"));
|
||||
add(0x28, 0x10, "US", [2, 0]);
|
||||
add(0x28, 0x11, "US", [2, 0]);
|
||||
add(0x28, 0x100, "US", [16, 0]);
|
||||
add(0x28, 0x101, "US", [12, 0]);
|
||||
add(0x28, 0x102, "US", [11, 0]);
|
||||
add(0x28, 0x103, "US", [1, 0]);
|
||||
add(0x28, 0x1050, "DS", text("0"));
|
||||
add(0x28, 0x1051, "DS", text("4096"));
|
||||
add(
|
||||
0x7fe0,
|
||||
0x10,
|
||||
"OW",
|
||||
[0, 8, 255, 15, 0, 0, 255, 7, 255, 7, 0, 0, 255, 15, 0, 8]
|
||||
);
|
||||
return new Uint8Array(data).buffer;
|
||||
}
|
||||
import { fixture } from "./fixtures/dicom";
|
||||
|
||||
describe("DICOM rendering", () => {
|
||||
it("preserves signed 12-bit CT values", () => {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
export function fixture() {
|
||||
const data: number[] = [...new Uint8Array(128), 68, 73, 67, 77];
|
||||
const add = (group: number, element: number, vr: string, bytes: number[]) => {
|
||||
if (bytes.length % 2) bytes.push(vr === "UI" ? 0 : 32);
|
||||
data.push(
|
||||
group & 255,
|
||||
group >> 8,
|
||||
element & 255,
|
||||
element >> 8,
|
||||
vr.charCodeAt(0),
|
||||
vr.charCodeAt(1)
|
||||
);
|
||||
if (["OB", "OW"].includes(vr))
|
||||
data.push(0, 0, bytes.length & 255, bytes.length >> 8, 0, 0);
|
||||
else data.push(bytes.length & 255, bytes.length >> 8);
|
||||
data.push(...bytes);
|
||||
};
|
||||
const text = (s: string) => Array.from(new TextEncoder().encode(s));
|
||||
add(2, 0x10, "UI", text("1.2.840.10008.1.2.1"));
|
||||
add(0x28, 2, "US", [1, 0]);
|
||||
add(0x28, 4, "CS", text("MONOCHROME2"));
|
||||
add(0x28, 8, "IS", text("2"));
|
||||
add(0x28, 0x10, "US", [2, 0]);
|
||||
add(0x28, 0x11, "US", [2, 0]);
|
||||
add(0x28, 0x100, "US", [16, 0]);
|
||||
add(0x28, 0x101, "US", [12, 0]);
|
||||
add(0x28, 0x102, "US", [11, 0]);
|
||||
add(0x28, 0x103, "US", [1, 0]);
|
||||
add(0x28, 0x1050, "DS", text("0"));
|
||||
add(0x28, 0x1051, "DS", text("4096"));
|
||||
add(
|
||||
0x7fe0,
|
||||
0x10,
|
||||
"OW",
|
||||
[0, 8, 255, 15, 0, 0, 255, 7, 255, 7, 0, 0, 255, 15, 0, 8]
|
||||
);
|
||||
return new Uint8Array(data).buffer;
|
||||
}
|
||||
Reference in new issue
Block a user