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 | import { StackViewport, Types } from '..';
import getEnabledElement from '../getEnabledElement';
/**
* Gets the IImage rendered by the given element. This is provided as a
* convenience for the legacy cornerstone getImage function. However it is
* encouraged for IStackViewport.getImage to be used instead.
* @param element - the element rendering/containing the image
* @returns the image
*/
function getImageLegacy(element: HTMLDivElement): Types.IImage | undefined {
const enabledElement = getEnabledElement(element);
if (!enabledElement) {
return;
}
const { viewport } = enabledElement;
if (!(viewport instanceof StackViewport)) {
throw new Error(
`An image can only be fetched for a stack viewport and not for a viewport of type: ${viewport.type}`
);
}
return viewport.getCornerstoneImage();
}
export default getImageLegacy;
|