From 53d5f0ce063f4bf4d2f28beae3158b47bc848012 Mon Sep 17 00:00:00 2001 From: David2k13 <1096486917@qq.com> Date: Fri, 3 Mar 2023 15:27:39 +0800 Subject: [PATCH 1/3] feat: Updated the CLUT lookup: rgba style: eslint -fix --- ...ixelDataToCanvasImageDataPseudocolorLUT.js | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/internal/storedPixelDataToCanvasImageDataPseudocolorLUT.js b/src/internal/storedPixelDataToCanvasImageDataPseudocolorLUT.js index 8f60b193..38c77a7b 100644 --- a/src/internal/storedPixelDataToCanvasImageDataPseudocolorLUT.js +++ b/src/internal/storedPixelDataToCanvasImageDataPseudocolorLUT.js @@ -33,9 +33,31 @@ function storedPixelDataToCanvasImageDataPseudocolorLUT (image, grayscaleLut, co clut = colorLut; } - if (minPixelValue < 0) { + if (image.color === true || image.rgba === true) { /* Updated the CLUT lookup: rgba */ + if (minPixelValue < 0) { + while (storedPixelDataIndex < numPixels) { + grayscale = grayscaleLut[pixelData[storedPixelDataIndex] + -minPixelValue]; + storedPixelDataIndex += 4; + rgba = clut[grayscale]; + canvasImageDataData[canvasImageDataIndex++] = rgba[0]; + canvasImageDataData[canvasImageDataIndex++] = rgba[1]; + canvasImageDataData[canvasImageDataIndex++] = rgba[2]; + canvasImageDataData[canvasImageDataIndex++] = rgba[3]; + } + } else { + while (storedPixelDataIndex < numPixels) { + grayscale = grayscaleLut[pixelData[storedPixelDataIndex]]; + storedPixelDataIndex += 4; + rgba = clut[grayscale]; + canvasImageDataData[canvasImageDataIndex++] = rgba[0]; + canvasImageDataData[canvasImageDataIndex++] = rgba[1]; + canvasImageDataData[canvasImageDataIndex++] = rgba[2]; + canvasImageDataData[canvasImageDataIndex++] = rgba[3]; + } + } + } else if (minPixelValue < 0) { while (storedPixelDataIndex < numPixels) { - grayscale = grayscaleLut[pixelData[storedPixelDataIndex++] + (-minPixelValue)]; + grayscale = grayscaleLut[pixelData[storedPixelDataIndex++] + -minPixelValue]; rgba = clut[grayscale]; canvasImageDataData[canvasImageDataIndex++] = rgba[0]; canvasImageDataData[canvasImageDataIndex++] = rgba[1]; From fcd42117ad77aaeffcd1da03c1cd82586a6c4e64 Mon Sep 17 00:00:00 2001 From: cw2k13 <1096486917@qq.com> Date: Tue, 16 Jan 2024 16:52:08 +0800 Subject: [PATCH 2/3] perf: drawImageSyncHandler --- config/webpack/webpack-base.js | 4 ++-- package.json | 6 +++--- src/internal/drawImageSync.js | 5 ++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/config/webpack/webpack-base.js b/config/webpack/webpack-base.js index 238e12a0..c3e4d4af 100644 --- a/config/webpack/webpack-base.js +++ b/config/webpack/webpack-base.js @@ -26,7 +26,7 @@ module.exports = { devtool: 'source-map', externals: {}, module: { - rules: [{ + rules: [/* { enforce: 'pre', test: /\.js$/, exclude: /(node_modules)/, @@ -34,7 +34,7 @@ module.exports = { options: { failOnError: false } - }, { + },*/{ test: /\.js|ts$/, exclude: /(node_modules)/, use: [{ diff --git a/package.json b/package.json index 7684becc..cb3e5276 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "cornerstone-core", "version": "0.0.0-semantically-released", "description": "HTML5 Medical Image Viewer Component", - "main": "./dist/cornerstone.js", + "main": "./src/index.js", "keywords": [ "DICOM", "medical", @@ -11,7 +11,7 @@ "author": "Chris Hafey", "homepage": "https://github.com/cornerstonejs/cornerstone", "license": "MIT", - "module": "./dist/cornerstone.js", + "module": "./src/index.js", "repository": { "type": "git", "url": "https://github.com/cornerstonejs/cornerstone.git" @@ -56,7 +56,7 @@ "cz-conventional-changelog": "^3.3.0", "docdash": "^1.0.0", "documentation": "^13.2.5", - "eslint": "^5.5.0", + "eslint": "^6.8.0", "eslint-loader": "^2.1.0", "eslint-plugin-import": "^2.14.0", "gitbook-plugin-edit-link": "^2.0.2", diff --git a/src/internal/drawImageSync.js b/src/internal/drawImageSync.js index cae5ae7e..735db042 100644 --- a/src/internal/drawImageSync.js +++ b/src/internal/drawImageSync.js @@ -15,7 +15,7 @@ import EVENTS from '../events.js'; * @returns {void} * @memberof Internal */ -export default function (enabledElement, invalidated) { +export default async function (enabledElement, invalidated) { const image = enabledElement.image; const element = enabledElement.element; const layers = enabledElement.layers || []; @@ -53,6 +53,7 @@ export default function (enabledElement, invalidated) { } else { render = renderGrayscaleImage; } + image._render = render } render(enabledElement, invalidated); @@ -77,5 +78,7 @@ export default function (enabledElement, invalidated) { enabledElement.invalid = false; enabledElement.needsRedraw = false; + await globalThis.drawImageSyncHandler?.(eventData) + triggerEvent(element, EVENTS.IMAGE_RENDERED, eventData); } From 4c4ee6038e556571e0e9d41ac17cd5a7f5c378ec Mon Sep 17 00:00:00 2001 From: cw2k13 <1096486917@qq.com> Date: Thu, 7 Mar 2024 17:38:13 +0800 Subject: [PATCH 3/3] fix: renderColorImage with @Cornerstonejs/dicom-image-loader --- src/rendering/renderColorImage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rendering/renderColorImage.js b/src/rendering/renderColorImage.js index 1773b575..144af3ac 100644 --- a/src/rendering/renderColorImage.js +++ b/src/rendering/renderColorImage.js @@ -59,8 +59,8 @@ function getRenderCanvas (enabledElement, image, invalidated) { // The ww/wc is identity and not inverted - get a canvas with the image rendered into it for // Fast drawing - if (enabledElement.viewport.voi.windowWidth === 255 && - enabledElement.viewport.voi.windowCenter === 128 && + if ((enabledElement.viewport.voi.windowWidth === 255 || enabledElement.viewport.voi.windowWidth === 256) && + (enabledElement.viewport.voi.windowCenter === 127 || enabledElement.viewport.voi.windowCenter === 128) && enabledElement.viewport.invert === false && image.getCanvas && image.getCanvas()