コード例 #1
0
        /// <summary>
        /// 打开一张扫描切片
        /// </summary>
        /// <param name="path"></param>
        /// <param name="info">输出. 封装了切片信息</param>
        /// <returns>切片的宽高 (slideW, slideH) </returns>
        public void Open(string path, object info)
        {
            if (!(info is SceneGeometry))
            {
                throw new InvalidOperationException("Info is not MapGeometry type.");
            }
            if (OpenSlideImage.DetectFormat(path) == null)
            {
                throw new InvalidOperationException($"<<{path}>> is NOT a digital slide!");
            }
            slide = OpenSlideImage.Open(path);
            SceneGeometry sg = info as SceneGeometry;

            sg.Init();
            sg.SlideW = (int)slide.Width;
            sg.SlideH = (int)slide.Height;
            sg.L      = 0;
            sg.X      = sg.SlideW / 2;
            sg.Y      = sg.SlideH / 2;
            sg.NumL   = slide.LevelCount;
            for (int i = 0; i < sg.NumL; ++i)
            {
                sg.SetDensityAtLevel(i, slide.GetLevelDownsample(i));
            }
            thumbJpgBuf = slide.GetThumbnailAsJpeg(1024, 90);
        }
コード例 #2
0
 public void TestDetectFormat(string fileName, string format)
 {
     Assert.Equal(format, OpenSlideImage.DetectFormat(fileName));
 }