• [OHIF-Viewers]医疗数字阅片-医学影像-数字胶片直接下载,不再弹窗进行设置


    [OHIF-Viewers]医疗数字阅片-医学影像-数字胶片直接下载,不再弹窗进行设置

    直接下载解决方案

    ViewersextensionscornerstonesrccommandsModule.js

         showDownloadViewportModal: ({  viewports }) => {
           // 改变尺寸
           function doResize(width, height,el) {
             if (width < 100)
               width = 100
             if (height < 100)
               height = 100
     ​
             el.style.width = width + 'px';
             el.style.height = height + 'px';
             cornerstone.resize(el);
           }
           const activeViewportIndex = viewports.activeViewportIndex;
           const activeViewport = getEnabledElement(activeViewportIndex);
           const enabledElement = cornerstone.getEnabledElement(activeViewport);
           const viewport = Object.assign({}, enabledElement.viewport);
           delete viewport.scale;
           viewport.translation = {
             x: 0,
             y: 0,
           };
           const viewportElement = document.querySelector(".cornerstone-canvas-nn");
           cornerstone.enable(viewportElement); // 初始化
           // 插入数据
           cornerstone.loadAndCacheImage(enabledElement.image.imageId).then(function(image) {
                 cornerstone.displayImage(viewportElement, image); //插入图片
                 cornerstone.setViewport(viewportElement, viewport);//设置视图,设置现在显示的状态,如旋转等
                 cornerstone.resize(viewportElement, true);//先自适应调整一次,保证视图完整
           });
           //插入数据后,再执行尺寸的改变
           doResize(512,512,viewportElement) // 改变尺寸
           console.log(viewportElement);
           //延时
           setTimeout(function () {
             // alert('VIDEO HAS STOPPED');
             console.log("延迟执行");
             console.log(viewportElement.querySelector('canvas').toDataURL()); // 打印数据
             // console.log(document.querySelector("#root > div.FlexboxLayout > div.main-content > div > div > div > div.cornerstone-canvas-nn > canvas").toDataURL()); //绝对地址定位
             viewportElement.querySelector('canvas').toBlob(blob => {
               const URLObj = window.URL || window.webkitURL;
               const a = document.createElement('a');
               a.href = URLObj.createObjectURL(blob);
               a.download = 'imgs.jpg';
               document.body.appendChild(a);
               a.click();
               document.body.removeChild(a);
             });
             cornerstone.invalidate(viewportElement); // 删除el,一定要删除,不然连续下载,因为原始尺寸会产生插入数据不完整
           }, 500);
          },

    ViewersextensionscornerstonesrcOHIFCornerstoneViewport.js

    此位置添加cornerstone-canvas-nn标签

    测试过动态创建标签,但无法渲染出数据。document.createElement('div');

     <div className={"cornerstone-canvas-nn"} style={{position: 'absolute',left: '9999px'}}>
     </div>

     

     

  • 相关阅读:
    xml实现AOP
    AOP
    python 大小写转换方法(全)
    vs2013 快捷键
    构造方法后面带:this()
    资源的使用----实例分析
    把列表变成用指定字符连接的字符串
    python 列表、元组操作
    工作踩坑记录:JavaScript跳转被缓存
    《Effective Java》读书笔记
  • 原文地址:https://www.cnblogs.com/landv/p/13290410.html
Copyright © 2020-2023  润新知