@cornerstonejs/core 0.46.0 → 0.46.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/core",
3
- "version": "0.46.0",
3
+ "version": "0.46.2",
4
4
  "description": "",
5
5
  "main": "dist/umd/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -43,5 +43,5 @@
43
43
  "type": "individual",
44
44
  "url": "https://ohif.org/donate"
45
45
  },
46
- "gitHead": "5856c935d5879c1efa3a50930044d6526ed5c2c2"
46
+ "gitHead": "1e5e0ec2e760c409d532f14b145f52853a9f50ec"
47
47
  }
@@ -44,6 +44,7 @@ import applyPreset from './applyPreset';
44
44
  import deepMerge from './deepMerge';
45
45
  import getScalingParameters from './getScalingParameters';
46
46
  import getScalarDataType from './getScalarDataType';
47
+ import isPTPrescaledWithSUV from './isPTPrescaledWithSUV';
47
48
 
48
49
  // name spaces
49
50
  import * as planar from './planar';
@@ -89,6 +90,7 @@ export {
89
90
  snapFocalPointToSlice,
90
91
  getImageSliceDataForVolumeViewport,
91
92
  isImageActor,
93
+ isPTPrescaledWithSUV,
92
94
  actorIsA,
93
95
  getViewportsWithImageURI,
94
96
  getClosestStackImageIndexForPoint,
@@ -0,0 +1,7 @@
1
+ import { IImage } from '../types';
2
+
3
+ const isPTPrescaledWithSUV = (image: IImage) => {
4
+ return image.preScale?.scaled && image.preScale.scalingParameters?.suvbw;
5
+ };
6
+
7
+ export default isPTPrescaledWithSUV;
@@ -4,6 +4,7 @@ import StackViewport from '../RenderingEngine/StackViewport';
4
4
  import { IImage } from '../types';
5
5
  import { getRenderingEngine } from '../RenderingEngine/getRenderingEngine';
6
6
  import RenderingEngine from '../RenderingEngine';
7
+ import isPTPrescaledWithSUV from './isPTPrescaledWithSUV';
7
8
 
8
9
  /**
9
10
  * Renders an cornerstone image to a Canvas. This method will handle creation
@@ -43,6 +44,17 @@ export default function renderToCanvasGPU(
43
44
  element.style.visibility = 'hidden';
44
45
  element.style.position = 'absolute';
45
46
 
47
+ // Up-sampling the provided canvas to match the device pixel ratio
48
+ // since we use device pixel ratio to determine the size of the canvas
49
+ // inside the rendering engine.
50
+ const devicePixelRatio = window.devicePixelRatio || 1;
51
+ const originalWidth = canvas.width;
52
+ const originalHeight = canvas.height;
53
+ canvas.width = originalWidth * devicePixelRatio;
54
+ canvas.height = originalHeight * devicePixelRatio;
55
+ canvas.style.width = `${originalWidth}px`;
56
+ canvas.style.height = `${originalHeight}px`;
57
+
46
58
  document.body.appendChild(element);
47
59
 
48
60
  // add id to the element so we can find it later, and fix the : which is not allowed in css
@@ -84,7 +96,18 @@ export default function renderToCanvasGPU(
84
96
 
85
97
  // Copy the temporary canvas to the given canvas
86
98
  const context = canvas.getContext('2d');
87
- context.drawImage(temporaryCanvas, 0, 0);
99
+ context.drawImage(
100
+ temporaryCanvas,
101
+ 0,
102
+ 0,
103
+ temporaryCanvas.width,
104
+ temporaryCanvas.height, // source dimensions
105
+ 0,
106
+ 0,
107
+ canvas.width,
108
+ canvas.height // destination dimensions
109
+ );
110
+
88
111
  elementRendered = true;
89
112
 
90
113
  // remove based on id
@@ -112,7 +135,10 @@ export default function renderToCanvasGPU(
112
135
  element.addEventListener(Events.IMAGE_RENDERED, onImageRendered);
113
136
  viewport.renderImageObject(image);
114
137
 
115
- if (modality === 'PT' && !_isPTImagePreScaledWithSUV(image)) {
138
+ // force a reset camera to center the image
139
+ viewport.resetCamera();
140
+
141
+ if (modality === 'PT' && !isPTPrescaledWithSUV(image)) {
116
142
  viewport.setProperties({
117
143
  voiRange: {
118
144
  lower: image.minPixelValue,
@@ -124,7 +150,3 @@ export default function renderToCanvasGPU(
124
150
  viewport.render();
125
151
  });
126
152
  }
127
-
128
- const _isPTImagePreScaledWithSUV = (image: IImage) => {
129
- return image.preScale.scaled && image.preScale.scalingParameters.suvbw;
130
- };