Skip to content

CornerstoneImageRendered Event

Chris Hafey edited this page May 6, 2014 · 5 revisions

The CornerstoneImageRendered event call is emitted every time the image is redrawn by cornerstone. This event includes with it information that can be used to draw on the image using the HTML5 canvas context (e.g. geometry or text). You can also update HTML overlays with various viewport properties such as window width, window level and zoom.

Event Properties:

  • canvasContext - the canvas context for this image. Note that the context properties should be reset before drawing into them (see below)
  • renderTimeInMs - the time in ms it took to render the image. Mainly used to support development tasks such as optimization
  • viewport - the current viewport properties for this image
  • element - the DOM element that is enabled for this image
  • image - the image object for this image
  • enabledElement - an internal data structure that should not be used

Note: Cornerstone uses the generic DOM events mechanism to emit this event. Since the canvas context is supplied as part of this event and there may be multiple listeners, it is possible for a listener to leave the state of the canvas context in an unexpected state (e.g. scale, translation, line colors, etc). It is therefore prudent to explicitly set the canvas context state in your event handler. One way to do this is to call the setToPixelCoordinateSystem() to reset the transformation matrix before drawing on the canvas context.