This commit is contained in:
parent
ed2692908e
commit
1b9a6db73f
@ -337,10 +337,49 @@ async function makeSOPInstance(server, study, instance) {
|
|||||||
return sopInstance;
|
return sopInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert String to ArrayBuffer
|
||||||
|
*
|
||||||
|
* @param {String} str Input String
|
||||||
|
* @return {ArrayBuffer} Output converted ArrayBuffer
|
||||||
|
*/
|
||||||
|
function str2ab(str) {
|
||||||
|
const strLen = str.length;
|
||||||
|
const bytes = new Uint8Array(strLen);
|
||||||
|
|
||||||
|
for (let i = 0; i < strLen; i++) {
|
||||||
|
bytes[i] = str.charCodeAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bytes.buffer;
|
||||||
|
}
|
||||||
|
|
||||||
function getPaletteColor(server, instance, tag, lutDescriptor) {
|
function getPaletteColor(server, instance, tag, lutDescriptor) {
|
||||||
const numLutEntries = lutDescriptor[0];
|
const numLutEntries = lutDescriptor[0];
|
||||||
const bits = lutDescriptor[2];
|
const bits = lutDescriptor[2];
|
||||||
|
|
||||||
|
const readUInt16 = (byteArray, position) => {
|
||||||
|
return byteArray[position] + byteArray[position + 1] * 256;
|
||||||
|
};
|
||||||
|
|
||||||
|
const arrayBufferToPaletteColorLUT = arraybuffer => {
|
||||||
|
const byteArray = new Uint8Array(arraybuffer);
|
||||||
|
const lut = [];
|
||||||
|
|
||||||
|
if (bits === 16) {
|
||||||
|
for (let i = 0; i < numLutEntries; i++) {
|
||||||
|
lut[i] = readUInt16(byteArray, i * 2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (let i = 0; i < numLutEntries; i++) {
|
||||||
|
lut[i] = byteArray[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return lut;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (instance[tag].BulkDataURI) {
|
||||||
let uri = WADOProxy.convertURL(instance[tag].BulkDataURI, server);
|
let uri = WADOProxy.convertURL(instance[tag].BulkDataURI, server);
|
||||||
|
|
||||||
// TODO: Workaround for dcm4chee behind SSL-terminating proxy returning
|
// TODO: Workaround for dcm4chee behind SSL-terminating proxy returning
|
||||||
@ -358,27 +397,20 @@ function getPaletteColor(server, instance, tag, lutDescriptor) {
|
|||||||
BulkDataURI: uri,
|
BulkDataURI: uri,
|
||||||
};
|
};
|
||||||
|
|
||||||
const readUInt16 = (byteArray, position) => {
|
return dicomWeb
|
||||||
return byteArray[position] + byteArray[position + 1] * 256;
|
.retrieveBulkData(options)
|
||||||
};
|
.then(result => result[0])
|
||||||
|
.then(arrayBufferToPaletteColorLUT);
|
||||||
|
} else if (instance[tag].InlineBinary) {
|
||||||
|
const inlineBinaryData = atob(instance[tag].InlineBinary);
|
||||||
|
const arraybuf = str2ab(inlineBinaryData);
|
||||||
|
|
||||||
const arrayBufferToPaletteColorLUT = result => {
|
return arrayBufferToPaletteColorLUT(arraybuf);
|
||||||
const arraybuffer = result[0];
|
|
||||||
const byteArray = new Uint8Array(arraybuffer);
|
|
||||||
const lut = [];
|
|
||||||
|
|
||||||
for (let i = 0; i < numLutEntries; i++) {
|
|
||||||
if (bits === 16) {
|
|
||||||
lut[i] = readUInt16(byteArray, i * 2);
|
|
||||||
} else {
|
|
||||||
lut[i] = byteArray[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return lut;
|
throw new Error(
|
||||||
};
|
'Palette Color LUT was not provided as InlineBinary or BulkDataURI'
|
||||||
|
);
|
||||||
return dicomWeb.retrieveBulkData(options).then(arrayBufferToPaletteColorLUT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user