All files / packages/core/src/RenderingEngine/helpers/cpuFallback/rendering fitToWindow.ts

0% Statements 0/4
100% Branches 0/0
0% Functions 0/1
0% Lines 0/4

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                                             
import getImageFitScale from './getImageFitScale';
import { CPUFallbackEnabledElement } from '../../../../types';
 
/**
 * Adjusts an image's scale and translation so the image is centered and all pixels
 * in the image are viewable.
 *
 * @param element - The Cornerstone element to update
 */
export default function (enabledElement: CPUFallbackEnabledElement): void {
  const { image } = enabledElement;
 
  // The new scale is the minimum of the horizontal and vertical scale values
  enabledElement.viewport.scale = getImageFitScale(
    enabledElement.canvas,
    image,
    enabledElement.viewport.rotation
  ).scaleFactor;
 
  enabledElement.viewport.translation.x = 0;
  enabledElement.viewport.translation.y = 0;
}