How to use the cornerstone-core.loadAndCacheImage function in cornerstone-core

To help you get started, we’ve selected a few cornerstone-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GleasonBian / CornerstoneVueWADO / src / components / HelloWorld.vue View on Github external
console.log(
              "res.body.value.testDate.testDate1:",
              res.body.value.filmain
            );
            
            // 找到要渲染的元素
            let canvas = this.$refs.canvas;
            console.log(canvas);
            // 在 DOM 中将 canvas 元素注册到 cornerstone
            cornerstone.enable(canvas);
            // 拼接 url : cornerstoneWADOImageLoader 需要 wadouri 路径头
            const imageUrl = _this.baseUrl + _this.exampleStudyImageIds[0];
            let imageId = "wadouri:" + imageUrl;

            //  Load & Display
            cornerstone.loadAndCacheImage(imageId).then(
              function(image) {
                console.log(image);
                // 设置元素视口
                var viewport = cornerstone.getDefaultViewportForImage(
                  canvas,
                  image
                );
                // 显示图像
                cornerstone.displayImage(canvas, image, viewport);
                // 激活工具
                _this.initCanvasTools();
              },
              function(err) {
                alert(err);
              }
            );
github cornerstonejs / react-cornerstone-viewport / src / CornerstoneViewport / CornerstoneViewport.js View on Github external
try {
      // Setup "Stack State"
      cornerstoneTools.clearToolState(this.element, 'stack');
      cornerstoneTools.addStackStateManager(this.element, [
        'stack',
        'playClip',
        'referenceLines',
      ]);
      cornerstoneTools.addToolState(this.element, 'stack', {
        imageIds: [...imageIds],
        currentImageIdIndex: imageIdIndex,
      });

      // Load first image in stack
      const image = await cornerstone.loadAndCacheImage(imageId);

      // Display
      cornerstone.displayImage(this.element, image);

      if (isStackPrefetchEnabled) {
        _enableStackPrefetching(this.element);
      }

      if (isPlaying) {
        const validFrameRate = Math.max(frameRate, 1);
        cornerstoneTools.playClip(this.element, validFrameRate);
      }

      _addAndConfigureInitialToolsForElement(tools, this.element);
      _trySetActiveTool(this.element, this.props.activeTool);
      this.setState({ isLoading: false });
github cornerstonejs / react-cornerstone-viewport / src / CornerstoneViewport / CornerstoneViewport.js View on Github external
if (hasStackChanged) {
      // update stack toolstate
      cornerstoneTools.clearToolState(this.element, 'stack');
      cornerstoneTools.addToolState(this.element, 'stack', {
        imageIds: [...stack],
        currentImageIdIndex: imageIndex,
      });

      // New stack; reset counter
      updatedState['numImagesLoaded'] = 0;
      updatedState['error'] = null; // Reset error on new stack

      try {
        // load + display image
        const imageId = stack[imageIndex];
        const image = await cornerstone.loadAndCacheImage(imageId);

        cornerstone.displayImage(this.element, image);
        cornerstone.reset(this.element);
      } catch (err) {
        // :wave:
        // What if user kills component before `displayImage`?
      }
    } else if (!hasStackChanged && hasImageIndexChanged) {
      scrollToIndex(this.element, imageIndex);
    }

    const shouldStopStartStackPrefetch =
      (isStackPrefetchEnabled && hasStackChanged) ||
      (!prevIsStackPrefetchEnabled && isStackPrefetchEnabled === true);

    // Need to stop/start to pickup stack changes in prefetcher
github Kitware / paraview-glance / Sources / externals / MedicalCornerstone / CornerstoneRenderer.js View on Github external
publicAPI.render = (resetViewport = false) => {
    if (!model.container || !model.representation) {
      return;
    }

    const imageStack = model.representation.getImageStack();
    if (!imageStack) {
      return;
    }

    const imageId = imageStack.imageIds[imageStack.currentImageIdIndex];

    let promise;
    try {
      promise = cornerstone.loadAndCacheImage(imageId);
    } catch (error) {
      vtkErrorMacro(String(error));
      return;
    }

    promise
      .then((image) => {
        const viewport = Object.assign(
          {},
          cornerstone.getViewport(model.container)
        );

        if (resetViewport) {
          Object.assign(
            viewport,
            cornerstone.getDefaultViewportForImage(model.container, image)
github OHIF / react-vtkjs-viewport / examples / VTKLoadImageDataExample.js View on Github external
const promises = imageIds.map(imageId => {
      return cornerstone.loadAndCacheImage(imageId);
    });
github OHIF / react-vtkjs-viewport / examples / VTKCornerstonePaintingSyncExample.js View on Github external
const promises = imageIds.map(imageId => {
      return cornerstone.loadAndCacheImage(imageId);
    });