src/eventListeners/onImageRenderedBrushEventHandler.js
function _drawImageBitmap(evt, imageBitmap, alwaysVisible) {
  const eventData = evt.detail;
  const context = getNewContext(eventData.canvasContext.canvas);

  const canvasTopLeft = external.cornerstone.pixelToCanvas(eventData.element, {
    x: 0,
    y: 0,
  });

  const canvasTopRight = external.cornerstone.pixelToCanvas(eventData.element, {
    x: eventData.image.width,
    y: 0,
  });

  const canvasBottomRight = external.cornerstone.pixelToCanvas(
    eventData.element,
    {
      x: eventData.image.width,
      y: eventData.image.height,
    }
  );

  const cornerstoneCanvasWidth = external.cornerstoneMath.point.distance(
    canvasTopLeft,
    canvasTopRight
  );
  const cornerstoneCanvasHeight = external.cornerstoneMath.point.distance(
    canvasTopRight,
    canvasBottomRight
  );

  const canvas = eventData.canvasContext.canvas;
  const viewport = eventData.viewport;

  context.imageSmoothingEnabled = false;
  context.globalAlpha = getLayerAlpha(alwaysVisible);

  transformCanvasContext(context, canvas, viewport);

  const canvasViewportTranslation = {
    x: viewport.translation.x * viewport.scale,
    y: viewport.translation.y * viewport.scale,
  };

  context.drawImage(
    imageBitmap,
    canvas.width / 2 - cornerstoneCanvasWidth / 2 + canvasViewportTranslation.x,
    canvas.height / 2 -
      cornerstoneCanvasHeight / 2 +
      canvasViewportTranslation.y,
    cornerstoneCanvasWidth,
    cornerstoneCanvasHeight
  );

  context.globalAlpha = 1.0;

  resetCanvasContextTransform(context);
}
function _drawImageBitmap(evt, imageBitmap, alwaysVisible) {
  const eventData = evt.detail;
  const context = getNewContext(eventData.canvasContext.canvas);

  const canvasTopLeft = external.cornerstone.pixelToCanvas(eventData.element, {
    x: 0,
    y: 0,
  });

  const canvasTopRight = external.cornerstone.pixelToCanvas(eventData.element, {
    x: eventData.image.width,
    y: 0,
  });

  const canvasBottomRight = external.cornerstone.pixelToCanvas(
    eventData.element,
    {
      x: eventData.image.width,
      y: eventData.image.height,
    }
  );

  const cornerstoneCanvasWidth = external.cornerstoneMath.point.distance(
    canvasTopLeft,
    canvasTopRight
  );
  const cornerstoneCanvasHeight = external.cornerstoneMath.point.distance(
    canvasTopRight,
    canvasBottomRight
  );

  const canvas = eventData.canvasContext.canvas;
  const viewport = eventData.viewport;

  context.imageSmoothingEnabled = false;
  context.globalAlpha = getLayerAlpha(alwaysVisible);

  transformCanvasContext(context, canvas, viewport);

  const canvasViewportTranslation = {
    x: viewport.translation.x * viewport.scale,
    y: viewport.translation.y * viewport.scale,
  };

  context.drawImage(
    imageBitmap,
    canvas.width / 2 - cornerstoneCanvasWidth / 2 + canvasViewportTranslation.x,
    canvas.height / 2 -
      cornerstoneCanvasHeight / 2 +
      canvasViewportTranslation.y,
    cornerstoneCanvasWidth,
    cornerstoneCanvasHeight
  );

  context.globalAlpha = 1.0;

  resetCanvasContextTransform(context);
}
function _drawImageBitmap ( evt , imageBitmap , alwaysVisible ) { const eventData = evt . detail ; const context = getNewContext ( eventData . canvasContext . canvas ) ; const canvasTopLeft = external . cornerstone . pixelToCanvas ( eventData . element , { x : 0 , y : 0 , } ) ; const canvasTopRight = external . cornerstone . pixelToCanvas ( eventData . element , { x : eventData . image . width , y : 0 , } ) ; const canvasBottomRight = external . cornerstone . pixelToCanvas ( eventData . element , { x : eventData . image . width , y : eventData . image . height , } ) ; const cornerstoneCanvasWidth = external . cornerstoneMath . point . distance ( canvasTopLeft , canvasTopRight ) ; const cornerstoneCanvasHeight = external . cornerstoneMath . point . distance ( canvasTopRight , canvasBottomRight ) ; const canvas = eventData . canvasContext . canvas ; const viewport = eventData . viewport ; context . imageSmoothingEnabled = false ; context . globalAlpha = getLayerAlpha ( alwaysVisible ) ; transformCanvasContext ( context , canvas , viewport ) ; const canvasViewportTranslation = { x : viewport . translation . x * viewport . scale , y : viewport . translation . y * viewport . scale , } ; context . drawImage ( imageBitmap , canvas . width / 2 - cornerstoneCanvasWidth / 2 + canvasViewportTranslation . x , canvas . height / 2 - cornerstoneCanvasHeight / 2 + canvasViewportTranslation . y , cornerstoneCanvasWidth , cornerstoneCanvasHeight ) ; context . globalAlpha = 1.0 ; resetCanvasContextTransform ( context ) ; }
Draws the ImageBitmap the canvas.

@private
@param  {Object} evt description
@param {ImageBitmap} imageBitmap
@param {Boolean} alwaysVisible
@returns {void}
Draws the ImageBitmap the canvas .