@cornerstonejs/core 0.46.1 → 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/dist/cjs/utilities/renderToCanvasGPU.js +8 -1
- package/dist/cjs/utilities/renderToCanvasGPU.js.map +1 -1
- package/dist/esm/utilities/renderToCanvasGPU.js +8 -1
- package/dist/esm/utilities/renderToCanvasGPU.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +2 -2
- package/src/utilities/renderToCanvasGPU.ts +23 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/core",
|
|
3
|
-
"version": "0.46.
|
|
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": "
|
|
46
|
+
"gitHead": "1e5e0ec2e760c409d532f14b145f52853a9f50ec"
|
|
47
47
|
}
|
|
@@ -44,6 +44,17 @@ export default function renderToCanvasGPU(
|
|
|
44
44
|
element.style.visibility = 'hidden';
|
|
45
45
|
element.style.position = 'absolute';
|
|
46
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
|
+
|
|
47
58
|
document.body.appendChild(element);
|
|
48
59
|
|
|
49
60
|
// add id to the element so we can find it later, and fix the : which is not allowed in css
|
|
@@ -85,7 +96,18 @@ export default function renderToCanvasGPU(
|
|
|
85
96
|
|
|
86
97
|
// Copy the temporary canvas to the given canvas
|
|
87
98
|
const context = canvas.getContext('2d');
|
|
88
|
-
context.drawImage(
|
|
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
|
+
|
|
89
111
|
elementRendered = true;
|
|
90
112
|
|
|
91
113
|
// remove based on id
|