Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | 34x 34x 34x 34x 34x 34x 34x | import createViewport from './createViewport';
import getImageFitScale from './getImageFitScale';
import {
IImage,
CPUFallbackColormap,
CPUFallbackViewport,
} from '../../../../types';
/**
* Creates a new viewport object containing default values for the image and canvas
*
* @param canvas - A Canvas DOM element
* @param image - A Cornerstone Image Object
* @returns viewport - object
*/
export default function (
canvas: HTMLCanvasElement,
image: IImage,
modality?: string,
colormap?: CPUFallbackColormap
): CPUFallbackViewport {
Iif (canvas === undefined) {
throw new Error(
'getDefaultViewport: parameter canvas must not be undefined'
);
}
Iif (image === undefined) {
return createViewport();
}
// Fit image to window
const scale = getImageFitScale(canvas, image, 0).scaleFactor;
let voi;
Iif (modality === 'PT' && image.isPreScaled) {
voi = {
windowWidth: 5,
windowCenter: 2.5,
};
} else Eif (
image.windowWidth !== undefined &&
image.windowCenter !== undefined
) {
voi = {
windowWidth: Array.isArray(image.windowWidth)
? image.windowWidth[0]
: image.windowWidth,
windowCenter: Array.isArray(image.windowCenter)
? image.windowCenter[0]
: image.windowCenter,
};
}
return {
scale,
translation: {
x: 0,
y: 0,
},
voi,
invert: image.invert,
pixelReplication: false,
rotation: 0,
hflip: false,
vflip: false,
modalityLUT: image.modalityLUT,
modality,
voiLUT: image.voiLUT,
colormap: colormap !== undefined ? colormap : image.colormap,
displayedArea: {
tlhc: {
x: 1,
y: 1,
},
brhc: {
x: image.columns,
y: image.rows,
},
rowPixelSpacing:
image.rowPixelSpacing === undefined ? 1 : image.rowPixelSpacing,
columnPixelSpacing:
image.columnPixelSpacing === undefined ? 1 : image.columnPixelSpacing,
presentationSizeMode: 'NONE',
},
};
}
|